[EMAIL PROTECTED] misc]$ cat -n decl_friend_class.cpp
     1
     2  #ifdef DD
     3  class d;
     4  #endif
     5
     6  class c
     7  {
     8    friend class d;
     9    d* p;
    10  };
    11
[EMAIL PROTECTED] misc]$ /usr/local/gcc/gcc-4.0.0/bin/g++ -c -W -Wall 
decl_friend_class.cpp
[EMAIL PROTECTED] misc]$ /usr/local/gcc/gcc-4.0.1/bin/g++ -c -W -Wall 
decl_friend_class.cpp
decl_friend_class.cpp:9: error: ISO C++ forbids declaration of 'd' with no type
decl_friend_class.cpp:9: error: expected ';' before '*' token
[EMAIL PROTECTED] misc]$ /usr/local/gcc/gcc-4.0.1/bin/g++ -c -W -Wall 
-fpermissive
decl_friend_class.cpp
decl_friend_class.cpp:9: warning: ISO C++ forbids declaration of 'd' with no 
type
decl_friend_class.cpp:9: error: expected ';' before '*' token
[EMAIL PROTECTED] misc]$ /usr/local/gcc/gcc-4.0.1/bin/g++ -c -W -Wall -DDD
decl_friend_class.cpp
[EMAIL PROTECTED] misc]$ icc -c -w2 decl_friend_class.cpp
[EMAIL PROTECTED] misc]$

The icc here is icc 8.1

The original testcase comes from SystemC 2.0.1,
in include/systemc/kernel/sc_module_name.h

( http://www.systemc.org/ )

IANAC++LL.  It is not immediately clear to me from the
standard whether a friend class decl declares that class,
though the description of a friend function decl suggests
- to me, anyway - that it might.

I would be grateful if anyone could refer me to a discussion
of whether or not this is valid C++, acording to current
interpretations of the standard.

However:

I believe that this code is accepted by gcc-2.95, gcc-3.2.x, gcc-3.4.x,
gcc-4.0.0 without warning, so if it has been determined to be invalid,
it should reeceive a "deprecated" warning and/or require -fpermissive
before it ceases to be accepted by gcc.

Regards,

John.

I will test minor release candidates more in future...

-- 
           Summary: [regression 4.0.1 -> 4.0.0,3.4.x] Friend decl ceases to
                    declare class
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: John at xza5 dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22378

Reply via email to