On Thu, Mar 06, 2014 at 01:10:54PM -0800, Arthur O'Dwyer wrote:
> On Thu, Mar 6, 2014 at 1:03 PM, David Blaikie <[email protected]> wrote:
> > On Thu, Mar 6, 2014 at 12:15 PM, Joerg Sonnenberger 
> > <[email protected]> wrote:
> >> On Thu, Mar 06, 2014 at 04:27:18PM -0000, Marshall Clow wrote:
> >>>
> >>> -    static_assert((std::is_same<decltype(fabsf(0)), float>::value), "");
> >>> -    static_assert((std::is_same<decltype(fabsl(0)), long 
> >>> double>::value), "");
> >>> -    assert(fabs(-1) == 1);
> >>> +    static_assert((std::is_same<decltype(fabsf(0.f)), float>::value), 
> >>> "");
> >>> +    static_assert((std::is_same<decltype(fabsl(0.L)), long 
> >>> double>::value), "");
> >>> +    assert(fabs(-1.f) == 1);
> >>
> >> This looks bogus as in: it shouldn't warn here.
> >
> > What basis did you have in mind? That the constant is in the
> > representable range for the function being called, even though it's
> > not of the right type?
> 
> I guess it makes sense to warn about fabsf(int), because int->float
> conversion can be lossy.
> But surely fabs(int) and fabsl(int) are 100% fine!

There are two cases to distinguish here: constants and variable
arguments. I am fine with the warning for variable arguments, because
that would involve an implicit and potentially undesired float
conversion. Whether or not that is potentially lossy is not relevant for
me. On the other hand, with a constant (literal) argument, clang can
easily check whether the conversion gives the expected identical result.
I don't think it should warn then.

Joerg
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to