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

            Bug ID: 106264
           Summary: spurious -Wunused-value on a folded frexp, modf, and
                    remquo calls with unused result
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

In C mode only the following test case triggers the invalid (or at least poorly
worded and so confusing) instances of -Wunused-value.  Each instance goes away
when the call is not folded or when its result is used.  The C++ front end
doesn't warn.

$ cat a.c && gcc -O -Wall -S -Wall a.c
double frexp (double, int*);
double modf (double, double*);
double remquo (double, double, int*);

int f (void)
{
  int y;
  frexp (1.0, &y);
  return y;
}

double g (void)
{
  double y;
  modf (1.0, &y);
  return y;
}

int h (void)
{
  int y;
  remquo (1.0, 1.0, &y);
  return y;
}

a.c: In function ‘f’:
a.c:8:3: warning: right-hand operand of comma expression has no effect
[-Wunused-value]
    8 |   frexp (1.0, &y);
      |   ^~~~~~~~~~~~~~~
a.c: In function ‘g’:
a.c:15:3: warning: right-hand operand of comma expression has no effect
[-Wunused-value]
   15 |   modf (1.0, &y);
      |   ^~~~~~~~~~~~~~
a.c: In function ‘h’:
a.c:22:3: warning: right-hand operand of comma expression has no effect
[-Wunused-value]
   22 |   remquo (1.0, 1.0, &y);
      |   ^~~~~~~~~~~~~~~~~~~~~

Reply via email to