public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/100702] New: Strict overflow warning regression in gcc 8 onwards
@ 2021-05-20 11:01 david at westcontrol dot com
  2021-05-20 11:33 ` [Bug c/100702] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: david at westcontrol dot com @ 2021-05-20 11:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100702
           Summary: Strict overflow warning regression in gcc 8 onwards
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: david at westcontrol dot com
  Target Milestone: ---

Incorrect code like this example relies on two's complement wrapping to do what
the programmer wanted:

void foo(int *a)
{
  int i;
  for (i=0; i<i+1; i++)
    a[i&256]=0;
}

Since signed integer overflow is undefined behaviour, gcc optimises code like
that to an infinite loop.  That's fair enough.  But it would always be helpful
with a warning about such cases.

For gcc 7 and below, gcc can generate a warning but only if
"-Wstrict-overflow=5" is used.

gcc 8 and above have no warning, even with that flag (and -Wall -Wextra -O2).


I realise that these things can change between versions due to re-arrangement
of compiler passes and other differences.  But is there a possibility of a
warning when assumptions about undefined behaviour lead to infinite loops? 
(The compiler knows the loop is infinite - it doesn't bother generating a
return opcode.)

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

end of thread, other threads:[~2021-09-05 22:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-20 11:01 [Bug c/100702] New: Strict overflow warning regression in gcc 8 onwards david at westcontrol dot com
2021-05-20 11:33 ` [Bug c/100702] " rguenth at gcc dot gnu.org
2021-05-20 12:23 ` david at westcontrol dot com
2021-05-20 17:43 ` msebor at gcc dot gnu.org
2021-09-05 22:21 ` [Bug middle-end/100702] " pinskia at gcc dot gnu.org
2021-09-05 22:22 ` pinskia 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).