https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84589
Bug ID: 84589
Summary: Failure to diagnose conflicting declaration of struct
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Keywords: accepts-invalid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
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".