namespace-qualified unresolved-names
John McCall
rjmccall at apple.com
Sun Apr 24 06:22:16 UTC 2011
Consider the following:
namespace ns {
int foo(int);
short foo(short);
}
template <typename T> auto forward_foo(T t) -> decltype(ns::foo(t)) {
return ns::foo(t);
}
short test(short x) { return forward_foo(x); }
gcc-4.6 mangles forward_foo<short> as:
_Z11forward_fooIsEDTcl3foofp_EET_
This seems obviously wrong: the qualifier has completely disappeared,
and this now looks like an unqualified call. I believe the correct
mangling falls under the fourth production for <unresolved-name>:
<unresolved-name> ::= [gs] sr <unresolved-qualifier-level>+ E <base-unresolved-name>
In that case, the mangling should be:
_Z11forward_fooIsEDTclsr2nsE3foofp_EET_
Right? I just want to verify that, because I have some follow-ups. :)
1. When mangling a namespace qualifier for an unresolved-name,
should we mangle the full namespace path or just what was written?
namespace outer {
namespace ns { ... }
template <typename T> auto forward_foo(T t) -> decltype(ns::foo(t));
// sr2nsE3foo or sr5outer2nsE3foo or gssr5outer2nsE3foo ?
}
The 'gs' does not seem to be useful in the case of a non-member
unresolved-name with a qualifier.
2. Should we look through template aliases?
namespace alias = ns;
template <typename T> auto forward_foo(T t) -> decltype(alias::foo(t));
// sr2nsE3foo or sr5aliasE3foo ?
2a. If we look through template aliases, what happens to prefix
nested name specifiers?
namespace nsx { namespace alias = ns; }
template <typename T> auto forward_foo(T t) -> decltype(nsx::alias::foo(t));
// sr2nsE3foo ?
2b. Specifically, what about global prefixes?
template <typename T> auto forward_foo(T t) -> decltype(::alias::foo(t));
// sr2nsE3foo or gssr2nsE3foo ?
John.
More information about the cxx-abi-dev
mailing list