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

Jason Merrill jason at redhat.com
Sat Jun 19 21:12:57 UTC 2010


On 06/19/2010 03:52 PM, Mike Herrick wrote:
> Could you expand on that?  How might access control depend on the template parameters in f1 above?

template <class T> struct B;

class A
{
   int i;
   friend struct B<int>;
} a;

template <class T>
struct B
{
   decltype (a.i) f() { }
};

B<int> b; // OK, B<int> is a friend of A
B<float> b2; // error, a.i is private

> It sounds to me that you agree that in more complicated cases the full expression should be mangled,

Yes.

> and you're wondering if perhaps the simple "decltype(p1)" case falls into that category?

And I think that case works fine either way.

>> Perhaps we should just always use the dependent mangling in template scope, as G++ does for sizeof.
>
> I'm not sure what you mean by "template scope".  Certainly some expressions in "template scope" are folded to constant results in current practice going back many years, and we wouldn't want to change that.  We could say that the new decltype/sizeof cases would always get a full expression, but there doesn't seem to be a good dividing line between "old" sizeof/decltype cases and "new" ones.  Though distinguishing between "old" and "new" cases would make it easier for backward compatibility (for example, introducing new manglings for static_cast, etc. in decltype expressions without breaking the existing ABI).

Ah, yes.  We always build up the sizeof expression, but then fold it away.

> We think it makes sense to mangle full expressions only for things that are dependent or value-dependent.

I'm sympathetic, but not sure what to do about the "access-dependent" 
case above.

Jason



More information about the cxx-abi-dev mailing list