https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67746

            Bug ID: 67746
           Summary: Mangled name is accepted for variables in
                    namespace-scope
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: roger.ferrer at bsc dot es
  Target Milestone: ---

Hi,

this was discovered by accident.

g++ 5.2.0 accepts this

 namespace N
 {
   int x;
 }

 void f(void)
 {
   _ZN1N1xE = 1; // somehow this is an alias to N::x at the eyes of the C++FE
 }

but rejects other cases that have the same mangling (according to "nm") like

 struct N
 {
   static int x;
 };

 void f(void)
 {
   _ZN1N1xE = 1; // rejected
 }

The following case is not allowed either, which suggests that the mangled name
is added into some scope after the declarator has been processed.

 namespace N
 {
   int x = _ZN1N1xE; // rejected
 }

Next case is accepted, again suggesting that after the init-declarator 'x = 3'
has been consumed, the mangled name is added into some scope.

 namespace N
 {
   int x = 3, y = _ZN1N1xE; // accepted
 }

I understand that underscore-prefixed names may belong to the implementation,
but given that other similar cases are rejected, perhaps this one can be
rejected as well.

Kind regards,

Reply via email to