[Bug c++/44400] GCC allows declaring a function having the name of the class using a typedef

egallager at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Aug 14 15:22:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44400

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-08-14
                 CC|                            |egallager at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
Confirmed, g++ accepts it with neither warning nor error, while clang++ rejects
it like this:

$ /usr/local/bin/g++ -Wall -Wextra -pedantic -c 44400.cc
$ /sw/opt/llvm-3.1/bin/clang++ -Wall -Wextra -pedantic -c 44400.cc
44400.cc:2:14: error: member 'X' has the same name as its class
struct X { F X; };
             ^
44400.cc:2:14: error: constructor cannot have a return type
struct X { F X; };
           ~ ^
2 errors generated.
$


More information about the Gcc-bugs mailing list