public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/102606] New: miscompilation of a program with large array in a dead-code
@ 2021-10-05 11:48 k.even-mendoza at imperial dot ac.uk
  2021-10-05 11:52 ` [Bug middle-end/102606] large array in a dead-code is not optimized away at -O0 pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: k.even-mendoza at imperial dot ac.uk @ 2021-10-05 11:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102606
           Summary: miscompilation of a program with large array in a
                    dead-code
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: k.even-mendoza at imperial dot ac.uk
  Target Milestone: ---

This program miscompiled with gcc-12 (and also older versions) with -O0:

#include "stdio.h"
void foo(int *p)
{
  if(0) // Dead-code
  {
      int *i[(3500)][(300)];
  }
}
int main()
{
  int i = 1;
  foo(&i);
  printf("1\n");
  return 0;
}

the program terminates with Segmentation fault when compiled with -O0 and GCC,
but 
with -O1,O2,O3,Os and clang (all flags), it prints "1" and return 0. 
I assume the definition of "i" is being pulled up, out side the if(0) block.
I used gcc (GCC) 12.0.0 20210811 (experimental).

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

end of thread, other threads:[~2021-10-08 20:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-05 11:48 [Bug c/102606] New: miscompilation of a program with large array in a dead-code k.even-mendoza at imperial dot ac.uk
2021-10-05 11:52 ` [Bug middle-end/102606] large array in a dead-code is not optimized away at -O0 pinskia at gcc dot gnu.org
2021-10-05 12:08 ` rguenth at gcc dot gnu.org
2021-10-05 16:17 ` jakub at gcc dot gnu.org
2021-10-05 18:02 ` k.even-mendoza at imperial dot ac.uk
2021-10-08 20:47 ` 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).