This is reduced ../cstdlib file (without second using directive): // ----- test.cpp ----------------------------- namespace __gnu_cxx { void llabs(long long x); } namespace std { using __gnu_cxx::llabs; using __gnu_cxx::llabs; } // ------------------------------- Compilation of this code cause GCC to print: test.cpp:9: `llabs' is already declared in this scope This bug exists in gcc-3.1 up to gcc 3.2.2. It seems that verion 3.0.4 is ok. I haven't check 3.3 or 3.4 version. Bug does not occures if 1. compiling wiht -fno-builtin option 2. If using different function than llabs or llabs with different arguments list. 3. There is different namespace than std Release: gcc-3.1 up to 3.2.2 Environment: 1. Debian GNU/Linux Unstable Athlon XP 1600+, 512MB 2. Debian GNU/Linux Testing P4 1,7, 512MB How-To-Repeat: g++ test.cpp
Fix: Fixed in GCC 3.3, 3.4: http://gcc.gnu.org/ml/gcc-patches/2003-03/msg01020.html
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed. The problem has nothing to do with namespace __gnu_cxx, but indeed something with builtins. This code also shows the problem: ------------------------- namespace NS { void llabs(long long x); } namespace std { using NS::llabs; using NS::llabs; } ------------------ g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc x.cc:7: error: `llabs' is already declared in this scope If llabs is renamed to foo, then the code compiles cleanly. This seems like a bug. The problem occurs with 3.2, 3.3, and 3.4 branches. It doesn't happen with 3.0. W.
Responsible-Changed-From-To: unassigned->jason Responsible-Changed-Why: got it
State-Changed-From-To: analyzed->feedback State-Changed-Why: I'm not convinced this is a bug. namespace std is reserved to the implementation. Furthermore, if you fix the declaration of llabs to namespace NS { extern "C" long long llabs(long long x); } namespace std { using NS::llabs; using NS::llabs; } the testcase compiles fine.
From: mmitchel@gcc.gnu.org To: gcc-gnats@gcc.gnu.org Cc: Subject: c++/9924 Date: 11 Mar 2003 23:07:45 -0000 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2003-03-11 23:07:45 Modified files: gcc/cp : ChangeLog decl2.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/overload: builtin2.C Log message: PR c++/9924 * g++.dg/overload/builtin2.C: New test. 2003-03-11 Mark Mitchell <mark@codesourcery.com> PR c++/9924 * decl2.c (do_nonmember_using_decl): Ignore anticipated builtins. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3263&r2=1.3264 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&r1=1.604&r2=1.605 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2495&r2=1.2496 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/builtin2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
From: mmitchel@gcc.gnu.org To: gcc-gnats@gcc.gnu.org Cc: Subject: c++/9924 Date: 11 Mar 2003 23:07:46 -0000 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2003-03-11 23:07:45 Modified files: gcc/cp : ChangeLog decl2.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/overload: builtin2.C Log message: PR c++/9924 * g++.dg/overload/builtin2.C: New test. 2003-03-11 Mark Mitchell <mark@codesourcery.com> PR c++/9924 * decl2.c (do_nonmember_using_decl): Ignore anticipated builtins. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3263&r2=1.3264 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&r1=1.604&r2=1.605 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2495&r2=1.2496 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/builtin2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
From: mmitchel@gcc.gnu.org To: gcc-gnats@gcc.gnu.org Cc: Subject: c++/9924 Date: 11 Mar 2003 23:09:42 -0000 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: mmitchel@gcc.gnu.org 2003-03-11 23:09:42 Modified files: gcc/cp : ChangeLog decl2.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/overload: builtin2.C Log message: PR c++/9924 * g++.dg/overload/builtin2.C: New test. PR c++/9924 * decl2.c (do_nonmember_using_decl): Ignore anticipated builtins. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.76&r2=1.3076.2.77 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.575.2.18&r2=1.575.2.19 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.88&r2=1.2261.2.89 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/builtin2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
Responsible-Changed-From-To: jason->mmitchel Responsible-Changed-Why: you the man
State-Changed-From-To: feedback->closed State-Changed-Why: Mark's fix looks good to me.