auto limitation?

Maxim Fomin maxim at maxim-fomin.ru
Tue Sep 11 12:15:12 PDT 2012


On Tuesday, 11 September 2012 at 19:03:56 UTC, Namespace wrote:
>> I think it is UB rather than a bug. The spec says that return 
>> types must match exactly. AFAIK auto is a feature to infer 
>> return type, not to magically adjust to multiple incompatible 
>> types.
>
> But i thought Variant is one. ;)

I guess (never used Variant) that it uses templated getter which 
correctly returns value. Float values are returned in %xmm 
registers and integer values are returned in %eax. Without 
knowing return type a caller doesn't know where to take return 
value. For example in this case foo function correctly places 
return values, but main takes in both cases return value from 
%xmm.




More information about the Digitalmars-d-learn mailing list