[Bug c++/86600] New: Class declaration in the same declarative region as using declaration - Missing diagnostic message

zhonghao at pku dot org.cn gcc-bugzilla@gcc.gnu.org
Fri Jul 20 06:18:00 GMT 2018


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

            Bug ID: 86600
           Summary: Class declaration in the same declarative region as
                    using declaration - Missing diagnostic message
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhonghao at pku dot org.cn
  Target Milestone: ---

The following program should give a diagnostic message when trying to compile
it.

namespace X { class A; }

namespace Y { using X::A; class A {}; }

int main() {}

This is because it violates [basic.scope.declarative]/4 in the c++ standard:

  http://eel.is/c++draft/basic.scope.declarative#4

The diagnostic message is missing. MSVS gives a diagnostic message for this
program, but clang does not.

Stack overflow post confirming the bug:

 
http://stackoverflow.com/questions/31220154/class-declaration-in-same-scope-as-using-declaration-compiles-in-gcc-but-not-msv

clang++ also gives an error message:

code0.cpp:3:27: error: declaration conflicts with target of using declaration
      already in scope
namespace Y { using X::A; class A {}; }
                          ^
code0.c.cpp:1:21: note: target of using declaration
namespace X { class A; }
                    ^
code0.c.cpp:3:24: note: using declaration
namespace Y { using X::A; class A {}; }
                       ^
1 error generated.


More information about the Gcc-bugs mailing list