public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/106264] New: spurious -Wunused-value on a folded frexp, modf,  and remquo calls with unused result
@ 2022-07-11 21:05 msebor at gcc dot gnu.org
  2022-07-11 21:07 ` [Bug c/106264] [10/11/12/13 Regression] " pinskia at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: msebor at gcc dot gnu.org @ 2022-07-11 21:05 UTC (permalink / raw)
  To: gcc-bugs

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);
      |   ^~~~~~~~~~~~~~~~~~~~~

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c/106264] [10/11/12/13 Regression] spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result
  2022-07-11 21:05 [Bug c/106264] New: spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result msebor at gcc dot gnu.org
@ 2022-07-11 21:07 ` pinskia at gcc dot gnu.org
  2022-07-11 21:09 ` pinskia at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-11 21:07 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|spurious -Wunused-value on  |[10/11/12/13 Regression]
                   |a folded frexp, modf, and   |spurious -Wunused-value on
                   |remquo calls with unused    |a folded frexp, modf, and
                   |result                      |remquo calls with unused
                   |                            |result
   Target Milestone|---                         |10.5
      Known to fail|                            |9.1.0
      Known to work|                            |8.1.0, 8.5.0

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c/106264] [10/11/12/13 Regression] spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result
  2022-07-11 21:05 [Bug c/106264] New: spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result msebor at gcc dot gnu.org
  2022-07-11 21:07 ` [Bug c/106264] [10/11/12/13 Regression] " pinskia at gcc dot gnu.org
@ 2022-07-11 21:09 ` pinskia at gcc dot gnu.org
  2022-07-11 21:13 ` msebor at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-11 21:09 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-07-11
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, started sometime between GCC 8 and GCC 9. It was folded even in GCC
8.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c/106264] [10/11/12/13 Regression] spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result
  2022-07-11 21:05 [Bug c/106264] New: spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result msebor at gcc dot gnu.org
  2022-07-11 21:07 ` [Bug c/106264] [10/11/12/13 Regression] " pinskia at gcc dot gnu.org
  2022-07-11 21:09 ` pinskia at gcc dot gnu.org
@ 2022-07-11 21:13 ` msebor at gcc dot gnu.org
  2022-07-11 21:16 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: msebor at gcc dot gnu.org @ 2022-07-11 21:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
The most likely culprit is r261705.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c/106264] [10/11/12/13 Regression] spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result
  2022-07-11 21:05 [Bug c/106264] New: spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result msebor at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-07-11 21:13 ` msebor at gcc dot gnu.org
@ 2022-07-11 21:16 ` pinskia at gcc dot gnu.org
  2022-07-12  6:38 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-11 21:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #2)
> The most likely culprit is r261705.

Yes this part:

(fold_builtin_n): Avoid setting TREE_NO_WARNING.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c/106264] [10/11/12/13 Regression] spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result
  2022-07-11 21:05 [Bug c/106264] New: spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result msebor at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-07-11 21:16 ` pinskia at gcc dot gnu.org
@ 2022-07-12  6:38 ` rguenth at gcc dot gnu.org
  2022-07-15  8:34 ` [Bug c/106264] [10/11/12/13 Regression] spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result since r9-1295-g781ff3d80e88d7d0 marxin at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-07-12  6:38 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c/106264] [10/11/12/13 Regression] spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result since r9-1295-g781ff3d80e88d7d0
  2022-07-11 21:05 [Bug c/106264] New: spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result msebor at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-07-12  6:38 ` rguenth at gcc dot gnu.org
@ 2022-07-15  8:34 ` marxin at gcc dot gnu.org
  2022-07-16 12:59 ` roger at nextmovesoftware dot com
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-07-15  8:34 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org
           Keywords|needs-bisection             |
            Summary|[10/11/12/13 Regression]    |[10/11/12/13 Regression]
                   |spurious -Wunused-value on  |spurious -Wunused-value on
                   |a folded frexp, modf, and   |a folded frexp, modf, and
                   |remquo calls with unused    |remquo calls with unused
                   |result                      |result since
                   |                            |r9-1295-g781ff3d80e88d7d0

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
Yes, started with r9-1295-g781ff3d80e88d7d0.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c/106264] [10/11/12/13 Regression] spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result since r9-1295-g781ff3d80e88d7d0
  2022-07-11 21:05 [Bug c/106264] New: spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result msebor at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2022-07-15  8:34 ` [Bug c/106264] [10/11/12/13 Regression] spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result since r9-1295-g781ff3d80e88d7d0 marxin at gcc dot gnu.org
@ 2022-07-16 12:59 ` roger at nextmovesoftware dot com
  2022-07-19  7:40 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: roger at nextmovesoftware dot com @ 2022-07-16 12:59 UTC (permalink / raw)
  To: gcc-bugs

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

Roger Sayle <roger at nextmovesoftware dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |roger at nextmovesoftware dot com
           Assignee|unassigned at gcc dot gnu.org      |roger at nextmovesoftware dot com
             Status|NEW                         |ASSIGNED

--- Comment #5 from Roger Sayle <roger at nextmovesoftware dot com> ---
Patch proposed:
https://gcc.gnu.org/pipermail/gcc-patches/2022-July/598480.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c/106264] [10/11/12/13 Regression] spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result since r9-1295-g781ff3d80e88d7d0
  2022-07-11 21:05 [Bug c/106264] New: spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result msebor at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2022-07-16 12:59 ` roger at nextmovesoftware dot com
@ 2022-07-19  7:40 ` cvs-commit at gcc dot gnu.org
  2022-07-20  6:07 ` roger at nextmovesoftware dot com
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-19  7:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Roger Sayle <sayle@gcc.gnu.org>:

https://gcc.gnu.org/g:40f6e5912288256ee8ac41474f2dce7b6881c111

commit r13-1741-g40f6e5912288256ee8ac41474f2dce7b6881c111
Author: Roger Sayle <roger@nextmovesoftware.com>
Date:   Tue Jul 19 08:39:43 2022 +0100

    PR c/106264: Silence warnings from __builtin_modf et al.

    This middle-end patch resolves PR c/106264 which is a spurious warning
    regression caused by the tree-level expansion of modf, frexp and remquo
    producing "expression has no-effect" when the built-in function's result
    is ignored.  When these built-ins were first expanded at tree-level,
    fold_builtin_n would blindly set TREE_NO_WARNING for all built-ins. Now
    that we're more discerning, we should precisely call suppress_warning
    selectively on those COMPOUND_EXPRs that need them.

    2022-07-19  Roger Sayle  <roger@nextmovesoftware.com>
                Richard Biener  <rguenther@suse.de>

    gcc/ChangeLog
            PR c/106264
            * builtins.cc (fold_builtin_frexp): Call suppress_warning on
            COMPOUND_EXPR to silence spurious warning if result isn't used.
            (fold_builtin_modf): Likewise.
            (do_mpfr_remquo): Likewise.

    gcc/testsuite/ChangeLog
            PR c/106264
            * gcc.dg/pr106264.c: New test case.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c/106264] [10/11/12/13 Regression] spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result since r9-1295-g781ff3d80e88d7d0
  2022-07-11 21:05 [Bug c/106264] New: spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result msebor at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2022-07-19  7:40 ` cvs-commit at gcc dot gnu.org
@ 2022-07-20  6:07 ` roger at nextmovesoftware dot com
  2023-07-18 10:07 ` vincent-gcc at vinc17 dot net
  2023-07-18 12:42 ` roger at nextmovesoftware dot com
  10 siblings, 0 replies; 12+ messages in thread
From: roger at nextmovesoftware dot com @ 2022-07-20  6:07 UTC (permalink / raw)
  To: gcc-bugs

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

Roger Sayle <roger at nextmovesoftware dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED
   Target Milestone|10.5                        |13.0

--- Comment #7 from Roger Sayle <roger at nextmovesoftware dot com> ---
This has now been fixed on mainline for GCC 13.  Please feel free to reopen
this PR if folks consider this problem serious enough to backport the fix to
the release branches.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c/106264] [10/11/12/13 Regression] spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result since r9-1295-g781ff3d80e88d7d0
  2022-07-11 21:05 [Bug c/106264] New: spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result msebor at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2022-07-20  6:07 ` roger at nextmovesoftware dot com
@ 2023-07-18 10:07 ` vincent-gcc at vinc17 dot net
  2023-07-18 12:42 ` roger at nextmovesoftware dot com
  10 siblings, 0 replies; 12+ messages in thread
From: vincent-gcc at vinc17 dot net @ 2023-07-18 10:07 UTC (permalink / raw)
  To: gcc-bugs

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

Vincent Lefèvre <vincent-gcc at vinc17 dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vincent-gcc at vinc17 dot net

--- Comment #8 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
This seems to be the same issue as PR101090 ("incorrect -Wunused-value warning
on remquo with constant values"), which I had reported in 2021 and was present
in GCC 9 too.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c/106264] [10/11/12/13 Regression] spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result since r9-1295-g781ff3d80e88d7d0
  2022-07-11 21:05 [Bug c/106264] New: spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result msebor at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2023-07-18 10:07 ` vincent-gcc at vinc17 dot net
@ 2023-07-18 12:42 ` roger at nextmovesoftware dot com
  10 siblings, 0 replies; 12+ messages in thread
From: roger at nextmovesoftware dot com @ 2023-07-18 12:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Roger Sayle <roger at nextmovesoftware dot com> ---
*** Bug 101090 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-07-18 12:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-11 21:05 [Bug c/106264] New: spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result msebor at gcc dot gnu.org
2022-07-11 21:07 ` [Bug c/106264] [10/11/12/13 Regression] " pinskia at gcc dot gnu.org
2022-07-11 21:09 ` pinskia at gcc dot gnu.org
2022-07-11 21:13 ` msebor at gcc dot gnu.org
2022-07-11 21:16 ` pinskia at gcc dot gnu.org
2022-07-12  6:38 ` rguenth at gcc dot gnu.org
2022-07-15  8:34 ` [Bug c/106264] [10/11/12/13 Regression] spurious -Wunused-value on a folded frexp, modf, and remquo calls with unused result since r9-1295-g781ff3d80e88d7d0 marxin at gcc dot gnu.org
2022-07-16 12:59 ` roger at nextmovesoftware dot com
2022-07-19  7:40 ` cvs-commit at gcc dot gnu.org
2022-07-20  6:07 ` roger at nextmovesoftware dot com
2023-07-18 10:07 ` vincent-gcc at vinc17 dot net
2023-07-18 12:42 ` roger at nextmovesoftware dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).