Fixes are available
January 2009 PTF for XL C/C++ Enterprise Edition for AIX, V9.0
April 2009 PTF for XL C/C++ Enterprise Edition for AIX, V9.0
July 2009 PTF for XL C/C++ Enterprise Edition for AIX, V9.0
November 2010 PTF for XL C/C++ Enterprise Edition for AIX, V9.0
March 2011 PTF for XL C/C++ Enterprise Edition for AIX, V9.0
July 2011 PTF for XL C/C++ Enterprise Edition for AIX, V9.0
December 2011 PTF for XL C/C++ Enterprise Edition for AIX, V9.0
March 2012 PTF for XL C/C++ Enterprise Edition for AIX, V9.0
January 2010 PTF for XL C/C++ Enterprise Edition for AIX, V9.0
May 2010 PTF for XL C/C++ Enterprise Edition for AIX, V9.0
August 2010 PTF for XL C/C++ Enterprise Edition for AIX, V9.0
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:
Fix information
Fixed component name
XLC C++ AIX
Fixed component ID
5724S7100
Applicable component levels
Document Information
Modified date:
03 October 2021