[committed 03/12] libstdc++: Add macros for the inline namespace std::_V2
Jonathan Wakely
jwakely@redhat.com
Mon May 16 16:19:35 GMT 2022
On Mon, 16 May 2022 at 05:28, François Dumont via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> Based on what you told me recently maybe this patch is better. It does
> not change the link errors.
We need to be a little careful about just removing those macros.
For definitions that use qualified names, the macros are not needed.
For example:
namespace std { inline namespace __8 {
struct foo {
void bar(); // #1
};
} }
namespace std {
void foo::bar() { } // #2
}
The definition at #2 works correctly, because name lookup for 'foo'
finds std::__8::foo, so it's a definition of the member declared at
#1.
But if we have a definition using an unqualified name, that doesn't
work the same. For example:
namespace std { inline namespace __8 {
void func(); // #3
} }
namespace std {
void func() { } // #4
}
The definition at #4 doesn't need to do any name lookup, so it just
defines (and declares) a new function directly in namespace std. This
means we have std::__8::func declared at #3 and std::func declared at
#4, and so trying to call std::func() would be ambiguous.
So we don't need to _add_ the macros to files where the symbols are
already being defined correctly (which is why your recent patch was
not needed). And we can remove them from _some_ source files. But if
we remove all source files, some of those removals would be wrong.
More information about the Libstdc++
mailing list