https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95809
Bug ID: 95809
Summary: GCC treats inline namespace declaration as "ambiguous"
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: haoxintu at gmail dot com
Target Milestone: ---
This code, bug.cc, GCC fails to compile it, while clang, icc, or msvc accepts
it well.
$cat bug.cc
namespace g_namespace {}
inline namespace {
namespace g_namespace {}
}
namespace g_namespace {}
$g++ -c bug.cc
bug.cc:5:12: error: ‘namespace g_namespace’ is ambiguous
5 | namespace g_namespace {}
| ^~~~~~~~~~~
bug.cc:3:15: note: candidates are: ‘namespace <unnamed>::g_namespace { }’
3 | namespace g_namespace {}
| ^~~~~~~~~~~
bug.cc:1:11: note: ‘namespace g_namespace { }’
1 | namespace g_namespace {}
| ^~~~~~~~~~~
My GCC version is
g++ (GCC) 11.0.0 20200605 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
When I remove the keyword "inline", GCC accepts it well. So, I guess GCC might
can not detect the inline namespace declaration and separate its inside
namespace from outside ones.