[cxx-abi-dev] Decltype mangling and type dependency

Jason Merrill jason at redhat.com
Tue Jun 22 19:15:50 UTC 2010


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).  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
};

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.

Jason



More information about the cxx-abi-dev mailing list