public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/101090] New: incorrect -Wunused-value warning on remquo with constant values
@ 2021-06-16 10:27 vincent-gcc at vinc17 dot net
  2021-06-16 13:10 ` [Bug c/101090] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: vincent-gcc at vinc17 dot net @ 2021-06-16 10:27 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101090
           Summary: incorrect -Wunused-value warning on remquo with
                    constant values
           Product: gcc
           Version: 9.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincent-gcc at vinc17 dot net
  Target Milestone: ---

When remquo is used with constant values, GCC emits the following warning:
warning: right-hand operand of comma expression has no effect [-Wunused-value]

According to the following testcase compiled with the "-Wunused-value -c"
options, the warning is obtained only for f2, i.e. is does not occur when the
function is not called remquo or when non-constant values are used.

double r (double, double, int *);
double remquo (double, double, int *);

int f1 (void)
{
  int quo;
  r (1.0, 3.0, &quo);
  return quo;
}

int f2 (void)
{
  int quo;
  remquo (1.0, 3.0, &quo);
  return quo;
}

int f3 (double x, double y)
{
  int quo;
  remquo (x, y, &quo);
  return quo;
}

Testcase also available on https://godbolt.org/z/Px44sxn4h for testing, where I
can see that this bug was introduced in GCC 9.1.0 and is still present in the
trunk.

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

* [Bug c/101090] incorrect -Wunused-value warning on remquo with constant values
  2021-06-16 10:27 [Bug c/101090] New: incorrect -Wunused-value warning on remquo with constant values vincent-gcc at vinc17 dot net
@ 2021-06-16 13:10 ` rguenth at gcc dot gnu.org
  2023-07-18  9:53 ` vincent-gcc at vinc17 dot net
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-16 13:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
   Last reconfirmed|                            |2021-06-16
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
We warn about

(gdb) p expr
$2 = <compound_expr 0x7ffff669cbb8>
(gdb) p debug_generic_expr (expr)
quo = 0;, 1.0e+0

which is folded from the call via do_mpfr_remquo:

              /* Dereference the quo pointer argument.  */
              arg_quo = build_fold_indirect_ref (arg_quo);
              /* Proceed iff a valid pointer type was passed in.  */
              if (TYPE_MAIN_VARIANT (TREE_TYPE (arg_quo)) == integer_type_node)
                {
                  /* Set the value. */
                  tree result_quo
                    = fold_build2 (MODIFY_EXPR, TREE_TYPE (arg_quo), arg_quo,
                                   build_int_cst (TREE_TYPE (arg_quo),
                                                  integer_quo));
                  TREE_SIDE_EFFECTS (result_quo) = 1;
                  /* Combine the quo assignment with the rem.  */
                  result = non_lvalue (fold_build2 (COMPOUND_EXPR, type,
                                                    result_quo, result_rem));

but we should probably set TREE_NO_WARNING on the COMPOUND_EXPR.

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

* [Bug c/101090] incorrect -Wunused-value warning on remquo with constant values
  2021-06-16 10:27 [Bug c/101090] New: incorrect -Wunused-value warning on remquo with constant values vincent-gcc at vinc17 dot net
  2021-06-16 13:10 ` [Bug c/101090] " rguenth at gcc dot gnu.org
@ 2023-07-18  9:53 ` vincent-gcc at vinc17 dot net
  2023-07-18 10:09 ` vincent-gcc at vinc17 dot net
  2023-07-18 12:42 ` roger at nextmovesoftware dot com
  3 siblings, 0 replies; 5+ messages in thread
From: vincent-gcc at vinc17 dot net @ 2023-07-18  9:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
On Debian, I get a warning from GCC 9 to GCC 12 (Debian 12.3.0-6), but neither
with GCC 13 (Debian 13.1.0-8) nor with 14.0.0 20230612 (Debian 20230613-1).

So, has this bug been fixed (and where)?

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

* [Bug c/101090] incorrect -Wunused-value warning on remquo with constant values
  2021-06-16 10:27 [Bug c/101090] New: incorrect -Wunused-value warning on remquo with constant values vincent-gcc at vinc17 dot net
  2021-06-16 13:10 ` [Bug c/101090] " rguenth at gcc dot gnu.org
  2023-07-18  9:53 ` vincent-gcc at vinc17 dot net
@ 2023-07-18 10:09 ` vincent-gcc at vinc17 dot net
  2023-07-18 12:42 ` roger at nextmovesoftware dot com
  3 siblings, 0 replies; 5+ messages in thread
From: vincent-gcc at vinc17 dot net @ 2023-07-18 10:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
(In reply to Vincent Lefèvre from comment #2)
> So, has this bug been fixed (and where)?

This seems to be a particular case of PR106264, which was fixed in commit
r13-1741-g40f6e5912288256ee8ac41474f2dce7b6881c111.

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

* [Bug c/101090] incorrect -Wunused-value warning on remquo with constant values
  2021-06-16 10:27 [Bug c/101090] New: incorrect -Wunused-value warning on remquo with constant values vincent-gcc at vinc17 dot net
                   ` (2 preceding siblings ...)
  2023-07-18 10:09 ` vincent-gcc at vinc17 dot net
@ 2023-07-18 12:42 ` roger at nextmovesoftware dot com
  3 siblings, 0 replies; 5+ 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=101090

Roger Sayle <roger at nextmovesoftware dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
                 CC|                            |roger at nextmovesoftware dot com
             Status|NEW                         |RESOLVED

--- Comment #4 from Roger Sayle <roger at nextmovesoftware dot com> ---
Many thanks to Vincent for spotting/confirming that his bug report is a
duplicate of PR 106264, which was fixed in GCC 13.

*** This bug has been marked as a duplicate of bug 106264 ***

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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-16 10:27 [Bug c/101090] New: incorrect -Wunused-value warning on remquo with constant values vincent-gcc at vinc17 dot net
2021-06-16 13:10 ` [Bug c/101090] " rguenth at gcc dot gnu.org
2023-07-18  9:53 ` vincent-gcc at vinc17 dot net
2023-07-18 10:09 ` 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).