9924 – [3.2 regression] Multiple using statements for builtin functions not allowed (original) (raw)
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
- compiling wiht -fno-builtin option
- If using different function than llabs or llabs with different arguments list.
- There is different namespace than std
Release: gcc-3.1 up to 3.2.2
Environment:
- Debian GNU/Linux Unstable Athlon XP 1600+, 512MB
- Debian GNU/Linux Testing P4 1,7, 512MB
How-To-Repeat: g++ test.cpp
Comment 2 Wolfgang Bangerth 2003-03-03 19:47:23 UTC
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.Comment 3 Jason Merrill 2003-03-11 22:59:37 UTC
Responsible-Changed-From-To: unassigned->jason Responsible-Changed-Why: got it
Comment 4 Jason Merrill 2003-03-11 23:06:26 UTC
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.Comment 9 Jason Merrill 2003-03-12 20:50:47 UTC
Responsible-Changed-From-To: jason->mmitchel Responsible-Changed-Why: you the man
Comment 10 Jason Merrill 2003-03-12 20:50:47 UTC
State-Changed-From-To: feedback->closed State-Changed-Why: Mark's fix looks good to me.