public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/98630] New: Seg-fault when using a goto after condition (if)
@ 2021-01-11 22:48 k.even-mendoza at imperial dot ac.uk
  2021-01-12  8:11 ` [Bug tree-optimization/98630] " rguenth at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: k.even-mendoza at imperial dot ac.uk @ 2021-01-11 22:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98630
           Summary: Seg-fault when using a goto after condition (if)
           Product: gcc
           Version: 10.2.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: ---

The following code snippet:

unsigned b=0; 
unsigned d=0;
static unsigned g = 1;
unsigned foo (unsigned ui1, unsigned ui2 ) { return (ui2 == 0) ? (ui1) : (ui1 %
ui2); }
unsigned j() {
  {
    unsigned *k = &b;
    unsigned *m = &d;
    unsigned **n = &m;
    unsigned ***o = &n;
    if (g)
      ;
    else
    p : {
      if (foo(2, *k)) {
        ***o = 0;
        return 2;
      }
    }
  }
  goto p;
}
int main() { j(); }

When compiling with GCC-10 (gcc-10 (Ubuntu 10.2.0-5ubuntu1~20.04) 10.2.0):
> gcc-10 -w -O2 r.c -pedantic -Wall -Wextra 
> ./a.out 
> Segmentation fault (core dumped)

The program in llvm, gcc-9, gcc-8, and gcc-7 exit without any output.  
> clang-11 -w -O0 r.c -pedantic -Wall -Wextra -fsanitize=undefined
> ./a.out
> 
or:
> clang-11 -w -O2 r.c -pedantic -Wall -Wextra
> ./a.out
> 
or:
> gcc-9 -w -O2 r.c -pedantic -Wall -Wextra 
> ./a.out

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

end of thread, other threads:[~2021-01-12 14:44 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-11 22:48 [Bug c/98630] New: Seg-fault when using a goto after condition (if) k.even-mendoza at imperial dot ac.uk
2021-01-12  8:11 ` [Bug tree-optimization/98630] " rguenth at gcc dot gnu.org
2021-01-12  8:22 ` rguenth at gcc dot gnu.org
2021-01-12  8:26 ` rguenth at gcc dot gnu.org
2021-01-12  8:29 ` [Bug c/98630] " rguenth at gcc dot gnu.org
2021-01-12  8:50 ` k.even-mendoza at imperial dot ac.uk
2021-01-12  8:51 ` k.even-mendoza at imperial dot ac.uk
2021-01-12 10:08 ` jakub at gcc dot gnu.org
2021-01-12 10:16 ` jakub at gcc dot gnu.org
2021-01-12 10:33 ` rguenth at gcc dot gnu.org
2021-01-12 10:40 ` jakub at gcc dot gnu.org
2021-01-12 10:43 ` jakub at gcc dot gnu.org
2021-01-12 14:34 ` k.even-mendoza at imperial dot ac.uk
2021-01-12 14:39 ` jakub at gcc dot gnu.org
2021-01-12 14:42 ` k.even-mendoza at imperial dot ac.uk
2021-01-12 14:44 ` jakub 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).