From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23507 invoked by alias); 18 Mar 2014 13:33:24 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 23484 invoked by uid 48); 18 Mar 2014 13:33:20 -0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/60565] Bogus not-in-scope error Date: Tue, 18 Mar 2014 13:33:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-03/txt/msg01580.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D60565 --- Comment #2 from Jonathan Wakely --- (In reply to patrick from comment #0) > $ g++ -c exc.C > exc.C:8:26: warning: declaration of =E2=80=98void B::foo()=E2=80=99 with = C language linkage > [enabled by default] > extern "C" void foo (); > ^ > exc.C:3:21: warning: conflicts with previous declaration =E2=80=98void A:= :foo()=E2=80=99 > [enabled by default] > extern "C" void foo () throw (); > ^ > exc.C:8:26: warning: due to different exception specifications [enabled by > default] > extern "C" void foo (); > ^ This inconsistency makes the declaration of B::foo() ill-formed. > exc.C: In function =E2=80=98int main()=E2=80=99: > exc.C:14:5: error: =E2=80=98foo=E2=80=99 is not a member of =E2=80=98B=E2= =80=99 > B::foo (); > ^ This does not correspond to the code above, I don't know whether the code or the error is what you mean to post. In either case, I don't think this is bogus. The function's name is "foo" f= or linkage purposes, but as it isn't declared in the global namespace you still need to qualify it to call it. If you call A::foo() it will compile, or if = you fix the ill-formed redeclaration as B::foo() then you can call it as B::foo= (). You cannot call it unqualified though (unless you add a using declaration or using directive or redeclare it at global scope). >>From gcc-bugs-return-446712-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Mar 18 13:37:52 2014 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 27974 invoked by alias); 18 Mar 2014 13:37:52 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 27928 invoked by uid 48); 18 Mar 2014 13:37:47 -0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/60565] Bogus not-in-scope error Date: Tue, 18 Mar 2014 13:37:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-03/txt/msg01581.txt.bz2 Content-length: 462 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60565 --- Comment #3 from Jonathan Wakely --- (In reply to patrick from comment #1) > Er, sorry, the call to "foo ()" within main ought to be "B::foo ()". OK, in that case you need to fix the declaration of B::foo() if you want to call it. I think G++ is ignoring the inconsistent declaration of B::foo(). I'm not sure if that's correct, or whether it should give an error at that point.