public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/22378] New: [regression 4.0.1 -> 4.0.0,3.4.x] Friend decl ceases to declare class
@ 2005-07-08 19:51 John at xza5 dot com
2005-07-08 19:54 ` [Bug c++/22378] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: John at xza5 dot com @ 2005-07-08 19:51 UTC (permalink / raw)
To: gcc-bugs
[jv@smith 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
[jv@smith misc]$ /usr/local/gcc/gcc-4.0.0/bin/g++ -c -W -Wall decl_friend_class.cpp
[jv@smith 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
[jv@smith 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
[jv@smith misc]$ /usr/local/gcc/gcc-4.0.1/bin/g++ -c -W -Wall -DDD
decl_friend_class.cpp
[jv@smith misc]$ icc -c -w2 decl_friend_class.cpp
[jv@smith 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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/22378] [regression 4.0.1 -> 4.0.0,3.4.x] Friend decl ceases to declare class
2005-07-08 19:51 [Bug c++/22378] New: [regression 4.0.1 -> 4.0.0,3.4.x] Friend decl ceases to declare class John at xza5 dot com
@ 2005-07-08 19:54 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-08 19:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-07-08 19:53 -------
The code is in fact invalid.
friend should not inject the class at all.
The reason why we did not have a deprecated period or allow it with -fpermissive is because we
actually got a bug report about accepting this invalid code.
Just add the forward declaration.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22378
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-07-08 19:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-08 19:51 [Bug c++/22378] New: [regression 4.0.1 -> 4.0.0,3.4.x] Friend decl ceases to declare class John at xza5 dot com
2005-07-08 19:54 ` [Bug c++/22378] " pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).