GCC Bugzilla – Bug 2294
using declaration confusion
Last modified: 2003-12-27 07:46:25 UTC
From the example in section 7.3.3 12 of the 1997 draft, gcc complains about the "using C::f" declaration. Release: gcc version 3.0 20010313 (prerelease) Environment: online compiler How-To-Repeat: from http://anubis.dkuug.dk/jtc1/sc22/open/n2356/dcl.html: namespace B { void f(int); void f(double); } namespace C { void f(int); void f(double); void f(char); } void h() { using B::f; // B::f(int) and B::f(double) using C::f; // C::f(int), C::f(double), and C::f(char) f('h'); // calls C::f(char) f(1); // error: ambiguous: B::f(int) or C::f(int) ? void f(int); // error: // f(int) conflicts with C::f(int) and B::f(int) }
State-Changed-From-To: open->analyzed State-Changed-Why: Confirm as a bug.
From: lerdsuwa@gcc.gnu.org To: gcc-gnats@gcc.gnu.org, nobody@gcc.gnu.org, theonetruekenny@yahoo.com Cc: Subject: Re: c++/2294 Date: 30 Mar 2001 07:57:13 -0000 Synopsis: using declaration confusion State-Changed-From-To: open->analyzed State-Changed-By: lerdsuwa State-Changed-When: Fri Mar 30 02:57:12 2001 State-Changed-Why: Confirm as a bug. http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=2294&database=gcc
From: Nathanael Nerode <neroden@twcny.rr.com> To: gcc-gnats@gcc.gnu.org, theonetruekenny@yahoo.com, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org Cc: Subject: Re: c++/2294 Date: Wed, 1 Jan 2003 08:11:25 -0500 Confirmed still present in mainline as of 2003-01-01, after new parser merge. The second 'using' declaration generates this error: error: `f' is already declared in this scope
Patch submitted: http://gcc.gnu.org/ml/gcc-patches/2003-10/msg02572.html
Updated patch from Giovanni Bajo: http://gcc.gnu.org/ml/gcc-patches/2003-11/msg00067.html
The patch has been approved for both mainline and 3.3 branch. See: http://gcc.gnu.org/ml/gcc-patches/2003-11/msg00652.html http://gcc.gnu.org/ml/gcc-patches/2003-11/msg00667.html Bernardo will soon commit the mainline patch to CVS on my behalf, but I will keep the PR open until the 3.3 backport is ready (in a few days).
Subject: Bug 2294 CVSROOT: /cvs/gcc Module name: gcc Changes by: bernie@gcc.gnu.org 2003-11-14 20:14:09 Modified files: gcc/cp : ChangeLog name-lookup.c Log message: PR c++/2294 * name-lookup.c (push_overloaded_decl): Always construct an OVERLOAD unless the declaration is a built-in. (set_namespace_binding): While binding OVERLOADs with only one declaration, we still need to call supplement_binding. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3761&r2=1.3762 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/name-lookup.c.diff?cvsroot=gcc&r1=1.20&r2=1.21
Subject: Bug 2294 CVSROOT: /cvs/gcc Module name: gcc Changes by: bernie@gcc.gnu.org 2003-11-14 20:41:04 Modified files: gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/lookup: using9.C Log message: PR c++/2294 * g++.dg/lookup/using9.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3194&r2=1.3195 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/using9.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 2294 CVSROOT: /cvs/gcc Module name: gcc Changes by: bernie@gcc.gnu.org 2003-11-15 19:34:57 Modified files: gcc/cp : ChangeLog name-lookup.c Log message: PR c++/2294 * name-lookup.c: Revert previous patch for PR c++/2294 to prevent build failure on libjava. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3762&r2=1.3763 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/name-lookup.c.diff?cvsroot=gcc&r1=1.21&r2=1.22
Patch was reverted because it was breaking libgcj bootstrap. I'm working on the new patch.
Patch take 2 posted here: http://gcc.gnu.org/ml/gcc-patches/2003-11/msg01725.html
Subject: Bug 2294 CVSROOT: /cvs/gcc Module name: gcc Changes by: giovannibajo@gcc.gnu.org 2003-12-07 15:23:31 Modified files: gcc/cp : ChangeLog name-lookup.c init.c except.c Log message: PR c++/2294 * name-lookup.c (push_overloaded_decl): Always construct an OVERLOAD unless the declaration is a built-in. (set_namespace_binding): While binding OVERLOADs with only one declaration, we still need to call supplement_binding. * init.c (build_new_1): Deal with an OVERLOAD set when looking up for _Jv_AllocObject. * except.c (build_throw): Likewise for _Jv_Throw. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3786&r2=1.3787 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/name-lookup.c.diff?cvsroot=gcc&r1=1.22&r2=1.23 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&r1=1.348&r2=1.349 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/except.c.diff?cvsroot=gcc&r1=1.160&r2=1.161
Revised patch: http://gcc.gnu.org/ml/gcc-patches/2003-12/msg00675.html Approval: http://gcc.gnu.org/ml/gcc-patches/2003-12/msg00686.html. I'll prepare and commit a 3.3 backport (requested by Gaby) in a few days, when I'm sure the patch is stable. I'll keep the bug open until the 3.3 patch goes in as well.
Yet another revision: http://gcc.gnu.org/ml/gcc-patches/2003-12/msg00857.html Approval: http://gcc.gnu.org/ml/gcc-patches/2003-12/msg00858.html
Subject: Bug 2294 CVSROOT: /cvs/gcc Module name: gcc Changes by: giovannibajo@gcc.gnu.org 2003-12-16 04:00:01 Modified files: gcc/cp : ChangeLog name-lookup.c Log message: PR c++/2294 * name-lookup.c (push_overloaded_decl): always construct an OVERLOAD if the declaration comes from an using declaration. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3807&r2=1.3808 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/name-lookup.c.diff?cvsroot=gcc&r1=1.25&r2=1.26
Fixed for 3.4.
Subject: Bug 2294 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: giovannibajo@gcc.gnu.org 2003-12-27 00:05:57 Modified files: gcc/cp : ChangeLog decl.c Log message: Backport from mainline. 2003-12-16 Giovanni Bajo <giovannibajo@gcc.gnu.org> PR c++/2294 * decl.c (push_overloaded_decl): always construct an OVERLOAD if the declaration comes from an using declaration. 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.229&r2=1.3076.2.230 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.965.2.66&r2=1.965.2.67
Subject: Bug 2294 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: giovannibajo@gcc.gnu.org 2003-12-27 00:30:14 Modified files: gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/lookup: using9.C Log message: Backport from mainline: 2003-11-14 Giovanni Bajo <giovannibajo@gcc.gnu.org> PR c++/2294 * g++.dg/lookup/using9.C: New test. Patches: 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.345&r2=1.2261.2.346 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/using9.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.12.1
The fix has been backported to the 3.3 branch. This bug is now fixed for any version of GCC since 3.3.3. Thanks!