public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redi at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/16021] New: Tests for container swap specialisations FAIL in debug mode Date: Wed, 16 Jun 2004 12:15:00 -0000 [thread overview] Message-ID: <20040616121506.16021.redi@gcc.gnu.org> (raw) All testsuite/23_containers/*/modifiers/swap.cc files FAIL to compile when _GLIBCXX_DEBUG is defined. The following code is adapted from the testsuite: #define _GLIBCXX_DEBUG #include <vector> struct T { int i; }; int swap_calls; namespace std { template<> void vector<T, allocator<T> >::swap(vector<T, allocator<T> >&) { ++swap_calls; } } // Should use vector specialization for swap. int main() { std::vector<T> A; std::vector<T> B; swap_calls = 0; std::swap(A, B); return swap_calls; } Compiling this gives: swap.cc:12: error: `allocator' was not declared in this scope swap.cc:12: error: template argument 2 is invalid swap.cc:12: error: variable or field `swap' declared void swap.cc:12: error: `int __gnu_debug_def::vector<T, std::allocator<T> >::swap' is not a static member of `class __gnu_debug_def::vector<T, std::allocator<T> >' swap.cc:12: error: expected primary-expression before ')' token swap.cc:13: error: expected `;' before '{' token The same error happens for all containers on 3.4 and mainline. The diagnostic is confusing, it first says allocator is not found, then identifies it as std::allocator in another diagnostic that seems to think the member function is static. A solution is to qualify allocator as std::allocator, but this shouldn't be necessary because _GLIBCXX_DEBUG shouldn't change the meaning of any conforming program. I *think* what might be happening is that in debug mode the "std" namespace is really "__gnu_debug" and the (non-debug) standard library is really in "_GLIBCXX_STD". This means that the unqualified name "allocator" looks up in __gnu_debug and the global namespace, and so doesn't find "_GLIBCXX_STD::allocator". But I don't think I've got that quite right. -- Summary: Tests for container swap specialisations FAIL in debug mode Product: gcc Version: 3.5.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: redi at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16021
next reply other threads:[~2004-06-16 12:15 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-06-16 12:15 redi at gcc dot gnu dot org [this message] 2004-06-17 2:04 ` [Bug libstdc++/16021] " redi at gcc dot gnu dot org 2004-06-28 20:11 ` bangerth at dealii dot org 2004-06-30 14:41 ` redi at gcc dot gnu dot org 2004-06-30 15:22 ` bangerth at dealii dot org 2004-06-30 17:32 ` giovannibajo at libero dot it 2004-06-30 17:36 ` bangerth at dealii dot org 2004-06-30 19:33 ` [Bug c++/16021] " bangerth at dealii dot org 2004-08-02 18:52 ` mmitchel at gcc dot gnu dot org 2004-08-29 18:55 ` mmitchel at gcc dot gnu dot org 2004-11-01 0:46 ` mmitchel at gcc dot gnu dot org 2005-02-12 22:33 ` pinskia at gcc dot gnu dot org 2005-05-19 17:30 ` mmitchel at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20040616121506.16021.redi@gcc.gnu.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).