The following code fails to compile on 3.4 and newer compilers: ------------------------------------------------- #include <functional> struct less : public std::less<int> {}; #include <set> ------------------------------------------------- $ g++-3.4 -c test.cc In file included from /usr/lib/gcc/i686-pc-cygwin/3.4.0/include/c++/set:67, from test.cc:6: /usr/lib/gcc/i686-pc-cygwin/3.4.0/include/c++/bits/stl_set.h:69: error: `less' h as not been declared The problem appears related to strong using. This is a reduced, epurated testcase: ------------------------------------------------- namespace NB {} namespace NA { using namespace NB; } namespace NB { using namespace NA __attribute__ ((strong)); struct Foo {}; } struct Foo : NB::Foo {}; namespace NA { Foo a; } ------------------------------------------------- test.ii:17: error: `Foo' does not name a type (note: I found this bug while cleaning up the testcase in PR 15855). Jason: can you have a look at this please?
I think the problem is that the attribute strong is not strong enough.
This affects Boost, I'm bumping the priority.
Jason, are you looking at this PR?
Reconfirmed. I see this failure many times in boost logs.
Jason, will you be able to look into this PR?
Reconfirmed, still several failures in Boost because of this.
I analyzed this PR again. The problem seems not related to attribute strong itself, but rather the way v3 namespaces work. Basically, without debug support, the failing code looks like: --------------------------------- namespace std { struct A {}; }; struct A; namespace std { A a; // std::A, OK! }; --------------------------------- Instead, with debug support, we end up with code like this: --------------------------------- namespace std { struct A {}; }; namespace __gnu_norm { using namespace std; }; struct A; namespace __gnu_norm { A a; // ambiguous! }; --------------------------------- hence the failure. There are at least two ways to fix this in v3: - Fully qualify all references to std names from code within namespace _GLIBCXX_STD (which expands to __gnu_norm in debug mode). This is hard because it's impossible to fully check it, and it's pervasive. E.g. bits/stl_set.h:69, use "std::less" instead of "less". - Define namespace __gnu_norm within namespace std. This could be easier because you probably have to touch *only* namespace definitions. Comments?
> - Fully qualify all references to std names from code within namespace > _GLIBCXX_STD (which expands to __gnu_norm in debug mode). This is hard because > it's impossible to fully check it, and it's pervasive. E.g. bits/stl_set.h:69, > use "std::less" instead of "less". Actually, this is already the case (modulo mistakes): we did this work a lot of time ago, *before* the strong using work. The only remaining occurrences of unqualified names are fixed as we find them (Jonathan is doing a great job here, and in fact he uses debug mode) or are there for a reason: if I remember correctly, this is the case of less<>. I'm pretty sure Gaby said something. Gaby? In case fixing that would be trivial, of course.
I found something in the archive: http://gcc.gnu.org/ml/libstdc++/2002-12/msg00009.html That's why we didn't qualify less & co... In mainline (vs v7-branch), where we still don't have anything special for those function objects, maybe we should add the qualifications?
There are others unqualified names as default template parmaters, for instance "allocator". A good testcase would be something like: ---------------------------------- struct less; struct allocator; struct vector; struct set; struct pair; struct map; /*....*/ #include <set> #include <vector> #include <map> #include <functional> /*....*/ ---------------------------------- which should compile without errors.
I see, thanks. Indeed, I don't remember having paid attention to default template arguments. Let's wait a bit for Gaby's opinion on the whole issue, and, in case, let's quickly fix those problems.
I saw a lot of recent traffic on this issue. As we're going to be releasing 3.4.4 soon, please commit any changes to the 3.4 branch ASAP.
Hi Mark. Actually, I think we are going to fix this only in 4_0/mainline. Other, similar, fixes went only to mainline/4_0 and the patch that goes in 4_0/mainline has *lots* of rejects in 3_4.
Also, it's *incorrect* to call this a "3.4 Regression" because happens only in debug-mode and debug-mode didn't exist at all before 3.4.
Fixed in 4.0.1; will not be fixed in 3.4.x.
Subject: Bug 18604 CVSROOT: /cvs/gcc Module name: gcc Changes by: paolo@gcc.gnu.org 2005-05-10 01:58:21 Modified files: libstdc++-v3 : ChangeLog libstdc++-v3/include/std: std_bitset.h libstdc++-v3/include/bits: deque.tcc stl_bvector.h stl_deque.h stl_list.h stl_map.h stl_multimap.h stl_multiset.h stl_set.h stl_vector.h vector.tcc Added files: libstdc++-v3/testsuite/23_containers/bitset: 18604.cc libstdc++-v3/testsuite/23_containers/deque: 18604.cc libstdc++-v3/testsuite/23_containers/list: 18604.cc libstdc++-v3/testsuite/23_containers/map: 18604.cc libstdc++-v3/testsuite/23_containers/set: 18604.cc libstdc++-v3/testsuite/23_containers/vector: 18604.cc Log message: 2005-05-09 Paolo Carlini <pcarlini@suse.de> Giovanni Bajo <giovannibajo@gcc.gnu.org> PR libstdc++/18604 * include/bits/deque.tcc: Fully qualify names from namespace std. * include/bits/stl_bvector.h: Likewise. * include/bits/stl_deque.h: Likewise. * include/bits/stl_list.h: Likewise. * include/bits/stl_map.h: Likewise. * include/bits/stl_multimap.h: Likewise. * include/bits/stl_multiset.h: Likewise. * include/bits/stl_set.h: Likewise. * include/bits/stl_vector.h: Likewise. * include/bits/vector.tcc: Likewise. * include/std/std_bitset.h: Likewise. * testsuite/23_containers/bitset/18604.cc: New. * testsuite/23_containers/deque/18604.cc: Likewise. * testsuite/23_containers/list/18604.cc: Likewise. * testsuite/23_containers/map/18604.cc: Likewise. * testsuite/23_containers/set/18604.cc: Likewise. * testsuite/23_containers/vector/18604.cc: Likewise. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.2994&r2=1.2995 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/std/std_bitset.h.diff?cvsroot=gcc&r1=1.28&r2=1.29 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/bitset/18604.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/deque/18604.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/list/18604.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/map/18604.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/set/18604.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/vector/18604.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/deque.tcc.diff?cvsroot=gcc&r1=1.20&r2=1.21 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_bvector.h.diff?cvsroot=gcc&r1=1.41&r2=1.42 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_deque.h.diff?cvsroot=gcc&r1=1.56&r2=1.57 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_list.h.diff?cvsroot=gcc&r1=1.47&r2=1.48 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_map.h.diff?cvsroot=gcc&r1=1.25&r2=1.26 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_multimap.h.diff?cvsroot=gcc&r1=1.24&r2=1.25 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_multiset.h.diff?cvsroot=gcc&r1=1.24&r2=1.25 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_set.h.diff?cvsroot=gcc&r1=1.23&r2=1.24 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_vector.h.diff?cvsroot=gcc&r1=1.53&r2=1.54 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/vector.tcc.diff?cvsroot=gcc&r1=1.22&r2=1.23
Subject: Bug 18604 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: paolo@gcc.gnu.org 2005-05-10 02:15:43 Modified files: libstdc++-v3 : ChangeLog libstdc++-v3/include/std: std_bitset.h libstdc++-v3/include/bits: deque.tcc stl_bvector.h stl_deque.h stl_list.h stl_map.h stl_multimap.h stl_multiset.h stl_set.h stl_vector.h vector.tcc Added files: libstdc++-v3/testsuite/23_containers/bitset: 18604.cc libstdc++-v3/testsuite/23_containers/deque: 18604.cc libstdc++-v3/testsuite/23_containers/list: 18604.cc libstdc++-v3/testsuite/23_containers/map: 18604.cc libstdc++-v3/testsuite/23_containers/set: 18604.cc libstdc++-v3/testsuite/23_containers/vector: 18604.cc Log message: 2005-05-09 Paolo Carlini <pcarlini@suse.de> Giovanni Bajo <giovannibajo@gcc.gnu.org> PR libstdc++/18604 * include/bits/deque.tcc: Fully qualify names from namespace std. * include/bits/stl_bvector.h: Likewise. * include/bits/stl_deque.h: Likewise. * include/bits/stl_list.h: Likewise. * include/bits/stl_map.h: Likewise. * include/bits/stl_multimap.h: Likewise. * include/bits/stl_multiset.h: Likewise. * include/bits/stl_set.h: Likewise. * include/bits/stl_vector.h: Likewise. * include/bits/vector.tcc: Likewise. * include/std/std_bitset.h: Likewise. * testsuite/23_containers/bitset/18604.cc: New. * testsuite/23_containers/deque/18604.cc: Likewise. * testsuite/23_containers/list/18604.cc: Likewise. * testsuite/23_containers/map/18604.cc: Likewise. * testsuite/23_containers/set/18604.cc: Likewise. * testsuite/23_containers/vector/18604.cc: Likewise. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.2917.2.44&r2=1.2917.2.45 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/std/std_bitset.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.28&r2=1.28.12.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/bitset/18604.cc.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/deque/18604.cc.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/list/18604.cc.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/map/18604.cc.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/set/18604.cc.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/vector/18604.cc.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/deque.tcc.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.20&r2=1.20.34.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_bvector.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.39.6.2&r2=1.39.6.3 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_deque.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.56&r2=1.56.6.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_list.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.47&r2=1.47.6.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_map.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.25&r2=1.25.40.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_multimap.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.24&r2=1.24.40.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_multiset.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.24&r2=1.24.44.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_set.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.23&r2=1.23.44.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_vector.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.53&r2=1.53.6.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/vector.tcc.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.22&r2=1.22.10.1
Thanks Paolo!