On 8/8/12, Richard Guenther <richard.guent...@gmail.com> wrote:
> On Aug 8, 2012 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...

I did not get to the structure I had accidentally.  However, with
the prior suggestion to preserve exact semantics to existing calls,
it is all moot because we cannot have overloading.

We can test whether the code is making double_ints with cross-sign
ints by adding undefined overloads.  I think we should do that and
make all such crossings explicit.  However, I want to wait for a
separate patch.

-- 
Lawrence Crowl

Reply via email to