https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89425

            Bug ID: 89425
           Summary: -Wabsolute-value warns in dead code
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jsm28 at gcc dot gnu.org
                CC: jamborm at gcc dot gnu.org
  Target Milestone: ---

Trying building glibc with -Wextra with GCC mainline shows up warnings from
-Wabsolute-value illustrated by the following test:

double f (double x) { return sizeof (x) == sizeof (float) ? __builtin_fabsf (x)
: __builtin_fabs (x); }

t.c: In function 'f':
t.c:1:61: warning: absolute value function '__builtin_fabsf' given an argument
of type 'double' but has parameter of type 'float' which may cause truncation
of value [-Wabsolute-value]
    1 | double f (double x) { return sizeof (x) == sizeof (float) ?
__builtin_fabsf (x) : __builtin_fabs (x); }
      |                                                            
^~~~~~~~~~~~~~~

As with a range of other warnings in the C front end, this one should not apply
if c_inhibit_evaluation_warnings, to avoid such useless warnings.  (I'm not
sure that will actually be sufficient to be able to use this warning when
building glibc, because _Generic and __builtin_choose_expr don't look like they
set c_inhibit_evaluation_warnings, but it's certainly a desirable improvement
to this warning.)

Reply via email to