Bug 9924 - [3.2 regression] Multiple using statements for builtin functions not allowed
Summary: [3.2 regression] Multiple using statements for builtin functions not allowed
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2.2
: P3 normal
Target Milestone: ---
Assignee: Mark Mitchell
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2003-03-03 19:26 UTC by yaqb
Modified: 2003-07-25 17:33 UTC (History)
2 users (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 yaqb 2003-03-03 19:26:00 UTC
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
Comment 1 yaqb 2003-03-03 19:26:00 UTC
Fix:
Fixed in GCC 3.3, 3.4:

  http://gcc.gnu.org/ml/gcc-patches/2003-03/msg01020.html
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 5 Mark Mitchell 2003-03-11 23:07:45 UTC
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
 

Comment 6 Mark Mitchell 2003-03-11 23:07:46 UTC
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
 

Comment 7 Mark Mitchell 2003-03-11 23:09:42 UTC
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
 

Comment 8 Mark Mitchell 2003-03-11 23:09:42 UTC
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
 
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.