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

            Bug ID: 71975
           Summary: In c++11/14 mode whitespaces are ignored between enum
                    or class type name and ::
           Product: gcc
           Version: 6.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gw.fossdev at gmail dot com
  Target Milestone: ---

Created attachment 38951
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38951&action=edit
Test case triggering the bug

Hello, 

I've got a wired behaviour with c++11 and enums or classes as return type of a
fully specified function residing in the global namespace. I.e.  with a line
like 

namespace bar {
  class foo {
    friend some_enum_type ::global_function(); 
  }; 
}

an error  "enum some_enum_type is not a class or namespace" is reported.
Attached is an according test case. 

Observations: 
* With std=c++03 this compiles fine, probably because in this case enums can 
  not be strongly typed and make use of "::".  

* With c++11 this code compiles not.  

* If the return type is a class this construct also fails to compile.

* If the return  type is an "int" then it always compiles. 

I've first reported this bug in Debian [1] and also against LLVM [2]. 

Especially, since these two mostly independently developed compilers choke on
this same construct I'm not sure whether this is actually a bug in the
compilers, or whether this is an error or undefined behaviour resulting from
the formulation of the C++ standard. 

Many thanks, 
Gert 

[1] https://bugs.debian.org/829604
[2] https://llvm.org/bugs/show_bug.cgi?id=28422

Reply via email to