Uninstantiated default argument handling issue

Abramo Bagnara abramo.bagnara at bugseng.com
Mon Nov 17 08:29:52 PST 2014


Il 17/11/2014 01:15, Douglas Gregor ha scritto:
> 
> 
> Sent from my iPhone
> 
>> On Nov 8, 2014, at 1:21 AM, Abramo Bagnara <abramo.bagnara at bugseng.com> wrote:
>>
>>
>> template<typename T> void f2(T a, T b = T()) { }
>>
>> void m() {
>>  f2(10);
>>  f2(10);
>>  f2(10);
>>  f2(10);
>> }
>>
>> Checking the AST generated for the source above I've seen that the
>> default argument expression is not instantiated in specialization of
>> function f2, but instead such transformation is done (and redone) in the
>> calls to f2.
>>
>> In this way:
>>
>> - we have dependent expr in the declaration of fully instantiated
>> functions (that is unexpected, at least for me)
>>
>> - we have multiple copies of the same expression (one for each call)
>>
>> Is this deliberate?
> 
> The point of instantiation is at the call site where the default argument is needed, so this is correct. 

I don't understand: despite point of instantiation (where I agree) I
don't think that different calls should get different instantiations in
the same translation unit... I'm missing something?

The point is that every call get a separate instantiation, while the
ParamDecl initializer in function instance is left untouched.

-- 
Abramo Bagnara

BUGSENG srl - http://bugseng.com
mailto:abramo.bagnara at bugseng.com



More information about the cfe-commits mailing list