IBM Support

IZ33823: Error being incorrectly generated by the xlC compiler

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • Problem:
    A friend declaration inside of a class inside of a namespace
    inside
    of an extern "C" block is incorrectly generating an error.
    
    =====Start of a.C======
    extern "C" {
      namespace N {
      struct A {
        friend void foo();
      };
      }
    }
    ==========End of a.C==============
    
    $xlC -c a.C
    "a.C", line 4.19: 1540-0434 (S) The friend function must also be
    declared in the enclosing block scope.
    

Local fix

  • You can also use a work around to solve the problem.  The
    original code had extern "C" around everything (i.e. the
    namespace and class definition).  This is overkill and can be
    confusing since the member functions have to follow the C++
    linkage.  If it is feasible you can look at changing the source
    code to something more accurate.  See the following example.
    This gives you an alternate to waiting for an interim compiler
    fix.  The work around is still valid C++ code and should be
    compiled by other compilers too.
    
    -- a-fix.C
    namespace N {
      extern "C" {
        void foo();
      }
      struct A {
        friend void foo();
      };
    }
    -- a-fix.C --
    This work around is more typical C++ code.  You should have
    better luck porting it from compiler to compiler.
    

Problem summary

  • Users who want to have a friend declaration inside a
    class/struct inside of a namespace inside of an extern "C"
    block. An incorrect error was generated.
    
    The original intent of the error is to catch friend declaration
    inside a local class (without prior declaration).
    We incorrectly applied the same check on a namespace inside of
    an extern "C" block.
    

Problem conclusion

  • Additional if statements are in place to distinguish a local
    class from a namespace inside of an extern "C" block before the
    check.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IZ33823

  • Reported component name

    XLC C++ AIX

  • Reported component ID

    5724S7100

  • Reported release

    900

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2008-10-03

  • Closed date

    2008-10-23

  • Last modified date

    2009-01-27

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

    IZ42383 LI74341 LI74785

Fix information

  • Fixed component name

    XLC C++ AIX

  • Fixed component ID

    5724S7100

Applicable component levels

[{"Line of Business":{"code":"LOB08","label":"Cognitive Systems"},"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSJT9L","label":"XL C\/C++"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"9.0"}]

Document Information

Modified date:
03 October 2021