[cfe-dev] Template specialization: why drop attributes?

Sharlet, Dillon dillon.sharlet at intel.com
Fri Jun 15 13:38:26 PDT 2012

What you said makes sense. However, maybe there is a separate issue, because I don't think the function has already been implicitly instantiated. I see the issue I described with the following program:

template < int N >
int Test(int x) __attribute__((custom))
	return x * N;

template < >
int Test < 1 > (int x) __attribute__((custom))
	return x;

int Call(int x) __attribute__((custom))
	return Test < 1 > (x);

When I compile this, the call to Test < 1 > is to a FunctionDecl that doesn't have the custom attribute, and I can see it getting removed by StripImplicitInstantiation when debugging.

That is the entire program, so I don't think that the implicit specialization has actually been requested until after the explicit specialization is defined.

Thank you for your help!


-----Original Message-----
From: Jordan Rose [mailto:jordan_rose at apple.com] 
Sent: Friday, June 15, 2012 1:30 PM
To: Sharlet, Dillon
Cc: cfe-dev at cs.uiuc.edu
Subject: Re: [cfe-dev] Template specialization: why drop attributes?

This function is only called when the instantiation has already been implicitly requested. This makes sense for most attributes because the use at the site of instantiation has probably already been fixed to use the default behavior. Is there a reason you can't provide your explicit specialization before its uses?


More information about the cfe-dev mailing list