On Wed, Aug 8, 2012 at 10:33 AM, Marc Glisse <marc.gli...@inria.fr> wrote:
> On Wed, 8 Aug 2012, Richard Guenther wrote:
>
>>>>> +  static double_int make (unsigned HOST_WIDE_INT cst);
>>>>> +  static double_int make (HOST_WIDE_INT cst);
>>>>> +  static double_int make (unsigned int cst);
>>>>> +  static double_int make (int cst);
>
> [...]
>
>>>> Btw, if HOST_WIDE_INT == int the above won't even compile.
>>>
>>>
>>> Is that true of any host?  I am not aware of any.  Anyway, it is
>>> moot if we remove the overloads.
>>
>>
>> Right.  I'd simply rely on int / unsigned int promotion to HOST_WIDE_INT
>> or unsigned HOST_WIDE_INT and only provide overloads for HOST_WIDE_INT
>> kinds anyway.
>
>
> Sadly, that doesn't work with the current C++ rules (there is a proposal to
> change that for C++1y):
>
> void f(long);
> void f(unsigned long);
> void g(int x){f(x);}
>
> e.cc: In function ‘void g(int)’:
> e.cc:3:18: error: call of overloaded ‘f(int&)’ is ambiguous
> e.cc:3:18: note: candidates are:
> e.cc:1:6: note: void f(long int)
> e.cc:2:6: note: void f(long unsigned int)

Ick ... I forgot that integer promotions do not apply for int -> long.
 So even f(1) would
be ambiguous, right?  So I suppose we have to bite the bullet and add overloads
for all (unsigned) integer types from int to HOST_WIDE_INT (if HOST_WIDE_INT
is long long then we have to add overloads for int, unsigned int, long and
unsigned long).

Or use template magic to force promotion to HOST_WIDE_INT for integer
types smaller than HOST_WIDE_INT...

Richard.

> --
> Marc Glisse

Reply via email to