Bug 84589 - Failure to diagnose conflicting declaration of struct
Summary: Failure to diagnose conflicting declaration of struct
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
: 86600 86665 (view as bug list)
Depends on:
Blocks: c++-lookup, c++-name-lookup
  Show dependency treegraph
 
Reported: 2018-02-27 13:49 UTC by Jonathan Wakely
Modified: 2021-12-10 21:09 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-07-20 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2018-02-27 13:49:55 UTC
void stat(struct stat*) { }

namespace ns
{
  using ::stat;
  struct stat { };
}


This should be ill-formed, because the function declaration also adds "struct stat" to the global namespace, so the using-declaration adds that to ns, and defining struct ns::stat should conflict.


Clang says:

using.cc:6:3: error: declaration conflicts with target of using declaration already in scope
  struct stat { };
  ^
using.cc:1:18: note: target of using declaration
void stat(struct stat*) { }
                 ^
using.cc:5:11: note: using declaration
  using ::stat;
          ^
1 error generated.


and EDG says:

"using.cc", line 6: error: class "stat" cannot be defined in the current scope
    struct stat { };
           ^

1 error detected in the compilation of "using.cc".
Comment 1 Jonathan Wakely 2018-07-20 11:58:53 UTC
*** Bug 86600 has been marked as a duplicate of this bug. ***
Comment 2 Jonathan Wakely 2018-07-20 11:59:29 UTC
Testcase from Bug 86600

namespace X { class A; }

namespace Y { using X::A; class A {}; }
Comment 3 Jonathan Wakely 2018-07-25 08:15:29 UTC
*** Bug 86665 has been marked as a duplicate of this bug. ***