This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/62116] New: Allowing redeclaration of global variable x using ::x
- From: "yaghmour.shafik at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 13 Aug 2014 03:17:00 +0000
- Subject: [Bug c++/62116] New: Allowing redeclaration of global variable x using ::x
- Auto-submitted: auto-generated
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