Bug 56090 - [DR1310] Injected-class-name treated as constructor name
Summary: [DR1310] Injected-class-name treated as constructor name
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-23 21:32 UTC by Klemens
Modified: 2021-10-26 07:57 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Klemens 2013-01-23 21:32:05 UTC
should compile, see ISO/IEC 14882:2011 §9.0.2


$ cat test.cpp
struct foo { foo::foo::foo::foo::foo::foo* bar; };

$ g++ test.cpp 
test.cpp:1:14: error: ‘foo::foo’ names the constructor, not the type

$ g++ -v
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.7.1/g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.7.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.7.1/work/gcc-4.7.1/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.7.1 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.1/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.1 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.1/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.1/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.1/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --without-ppl --without-cloog --enable-lto --enable-nls --without-included-gettext --with-system-zlib --enable-obsolete --disable-werror --enable-secureplt --enable-multilib --with-multilib-list=m32,m64 --enable-libmudflap --disable-libssp --enable-libgomp --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.7.1/python --enable-checking=release --disable-libgcj --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.7.1 p1.0, pie-0.5.3'
Thread model: posix
gcc version 4.7.1 (Gentoo 4.7.1 p1.0, pie-0.5.3)
Comment 1 Andrew Pinski 2013-01-23 21:41:16 UTC
This is related to bug 11764 and C++ defect report #147.
Comment 2 Andrew Pinski 2013-01-23 21:44:07 UTC
My reading of DR 147, makes this invalid code as foo::foo names the constructor.
Comment 3 Klemens 2013-01-23 22:32:47 UTC
I would argue that in 3.4.3.1.2 the constructor is not an acceptable lookup result, since it would result in the code being invalid.


Additionally, the following use of a type alias (where the constructor is clearly not an acceptable lookup result) does not compile on my g++-4.7.1:
struct foo { using bar = foo::foo::foo; };
Comment 4 Andrew Pinski 2021-08-07 23:14:19 UTC
GCC, clang, ICC and MSVC all say this is not a bug and the name is a constructor name in this context.
Comment 5 Jonathan Wakely 2021-08-09 09:49:34 UTC
This was clarified by Core DR 1310 https://wg21.link/cwg1310

foo::foo names the constructor, and so can only be used to declare the constructor as a friend, or in a using-declaration for inheriting constructors.