public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/98029] New: volatile triggers incorrect "warning: right-hand operand of comma expression has no effect [-Wunused-value]"
@ 2020-11-27 12:09 vincent-gcc at vinc17 dot net
  2020-11-27 13:12 ` [Bug c/98029] [11 Regression] volatile triggers incorrect "warning: right-hand operand of comma expression has no effect [-Wunused-value]" since r11-5188-g32934a4f45a72144 marxin at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: vincent-gcc at vinc17 dot net @ 2020-11-27 12:09 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98029
           Summary: volatile triggers incorrect "warning: right-hand
                    operand of comma expression has no effect
                    [-Wunused-value]"
           Product: gcc
           Version: 11.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: ---

With gcc (Debian 20201125-2) 11.0.0 20201125 (experimental) [master revision
a4d9837ee4b:97273aee415:b13dacdfb315675803982ad5a3098f7b55e6357a]

double f1 (void)
{
  double d;
  int i;

  for (d = 2.0, i = 0; i < 5; i++, d *= d)
    ;

  return d;
}

double f2 (void)
{
  volatile double d;
  int i;

  for (d = 2.0, i = 0; i < 5; i++, d *= d)
    ;

  return d;
}

yields the following incorrect warning when using "-Wunused-value":

tst.c: In function 'f2':
tst.c:17:10: warning: right-hand operand of comma expression has no effect
[-Wunused-value]
   17 |   for (d = 2.0, i = 0; i < 5; i++, d *= d)
      |        ~~^~~~~

Note that one gets a warning only for f2. The only difference is the
"volatile".

I found this when testing GNU MPFR (a similar code occurs in tests/tset_ld.c).

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

end of thread, other threads:[~2021-01-04 21:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-27 12:09 [Bug c/98029] New: volatile triggers incorrect "warning: right-hand operand of comma expression has no effect [-Wunused-value]" vincent-gcc at vinc17 dot net
2020-11-27 13:12 ` [Bug c/98029] [11 Regression] volatile triggers incorrect "warning: right-hand operand of comma expression has no effect [-Wunused-value]" since r11-5188-g32934a4f45a72144 marxin at gcc dot gnu.org
2020-11-28 22:26 ` uecker at eecs dot berkeley.edu
2020-12-07 12:45 ` rguenth at gcc dot gnu.org
2020-12-22 23:49 ` muecker at gwdg dot de
2020-12-23  8:05 ` muecker at gwdg dot de
2020-12-23 11:12 ` marxin at gcc dot gnu.org
2021-01-04 21:55 ` cvs-commit at gcc dot gnu.org

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).