[cxx-abi-dev] Decltype mangling and type dependency
David Vandevoorde
daveed at edg.com
Tue Jun 22 19:34:52 UTC 2010
On Jun 22, 2010, at 3:15 PM, Jason Merrill wrote:
> On 06/21/2010 05:51 PM, David Vandevoorde wrote:
>> But that's an error: The mangling doesn't matter at that point, no?
>
> Not in this case, certainly, since the return type isn't mangled.
>
>> I didn't think there is a valid case where access is the only disambiguator between two entities (from a mangling perspective, in particular). Did I get that wrong?
>
> Hmm. In general, errors are relevant to mangling because of SFINAE, but I'm not sure if that is possible in this case (even assuming that access control violations get added to SFINAE).
I thought we (the C++ committee) deliberately did _not_ put access control under SFINAE?
> Let's see:
>
> template <class T> struct C;
>
> class A
> {
> int i;
> friend struct C<int>;
> } a;
>
> class B
> {
> int i;
> friend struct C<float>;
> } b;
>
> template <class T>
> struct C
> {
> template <class U> decltype (a.i) f() { } // #1
> template <class U> decltype (b.i) f() { } // #2
This (#2) declaration is invalid because it's a redeclaration of #1. (And if they weren't they'd have distinct signatures.)
> };
>
> int main()
> {
> C<int>().f<int>(); // calls #1
> C<float>().f<float>(); // calls #2
> }
>
> OK, looks like we can create a situation where we have two different function templates with the same signature but different access restrictions.
I still don't see it: Even ignoring the redeclaration error and the fact that access errors aren't under SFINAE, don't these two have different signatures since they're members of distinct class types (C<int> vs. C<float>)?
Daveed
More information about the cxx-abi-dev
mailing list