From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14830 invoked by alias); 13 Aug 2014 03:17:10 -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 14816 invoked by uid 48); 13 Aug 2014 03:17:03 -0000 From: "yaghmour.shafik at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/62116] New: Allowing redeclaration of global variable x using ::x Date: Wed, 13 Aug 2014 03:17:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new 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: yaghmour.shafik at gmail dot com 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: 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-08/txt/msg00812.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62116 Bug ID: 62116 Summary: Allowing redeclaration of global variable x using ::x Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: yaghmour.shafik at gmail dot com Given the following code: int x; int main() { int(::x); //does not compile int(::x + 2); //compiles } gcc 4.9 will compile it without an error while gcc 4.8.x and clang 3.4 will generate an error. For gcc 4.8.x the error is: error: invalid use of qualified-name '::x' int(::x); //does not compile ^ and clang gives the following error: error: definition or redeclaration of 'x' cannot name the global scope int(::x); //does not compile ~~^ as far as I can tell both gcc 4.8.x and clang are correct here based on my reading of section 8.3 paragraph 6: int(::x) ; is equivalent to: int ::x ; which is not valid. The problem originally cam up in the following Stackoverflow question: http://stackoverflow.com/questions/24623071/is-typex-valid