public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "zhan3299 at purdue dot edu" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/98972] New: internal compiler error: Segmentation fault signal terminated program cc1plus Date: Fri, 05 Feb 2021 03:38:03 +0000 [thread overview] Message-ID: <bug-98972-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98972 Bug ID: 98972 Summary: internal compiler error: Segmentation fault signal terminated program cc1plus Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: zhan3299 at purdue dot edu Target Milestone: --- Hi, I have a crafted .cc program named crash1.cc. When I use both gcc-10 and g++-10 compile it, an internal compiler error occurs. I run it on Ubuntu 20.04 x64. Details are attached. --- crash1.cc starts ---- constexpr const short f() { return 1.2345 * 0 / 01e9; try { enum s { } a[] = { 0 };; __attribute__ ((noinline(2))); a || -1ULL; } catch (int x) { int a[] = { 0 }; struct s { }; struct t: s {} ; try { (x %= 0); (x == 0); l:; } catch (int x) { auto x = f(); struct s {}; struct l: s {} t; 0 - 0; 0 + 0; } [] ( union s {} ) {};f; (sizeof(x) == __builtin_popcount(x)); if (sizeof ((void) sizeof(char[1 - 2 * x]))) { register const ; extern void; ; asm("" : "=a"(x), "=d"(x) : "r" (x), "0" (x), "1" (x)); void; } else { for (unsigned int i = f(); i < .1; i++) { for (unsigned int i = (x == 0); i < &&l; i++) { ; __builtin_inf(); __builtin_alloca(1); alignof(x); ; class s { } ; asm volatile ("" : : : ); ; }; int a[] = {};; x; ; class s { } ; const ; x; ~-1 - 0; }; 0 << 0 >> 0; &f; s; __builtin_constant_p(2); ;; struct s restrict ; struct t: s {} ; }; } class &&l { } ;; } void T( int *x) { f(); } --- crash1.cc ends --- --- g++-10 version starts --- root@c0d53067e55a:~/docker_share/gcc# g++-10 --version g++-10 (Ubuntu 10.2.0-5ubuntu1~20.04) 10.2.0 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. root@c0d53067e55a:~/docker_share/gcc# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.2 LTS Release: 20.04 Codename: focal --- g++-10 version ends --- --- g++-10 crash log starts --- root@c0d53067e55a:~/docker_share/gcc# g++-10 crash1.cc crash1.cc: In function 'constexpr const short int f()': crash1.cc:1:55: warning: 'try' in 'constexpr' function only available with '-std=c++2a' or '-std=gnu++2a' 1 | constexpr const short f() { return 1.2345 * 0 / 01e9; try { enum s { } a[] = { 0 };; __attribute__ ((noinline(2))); a || -1ULL; } catch (int x) { int a[] = { 0 }; struct s { }; struct t: s {} ; try { (x %= 0); (x == 0); l:; } catch (int x) { auto x = f(); struct s {}; struct l: s {} t; 0 - 0; 0 + 0; } [] ( union s {} ) {};f; (sizeof(x) == __builtin_popcount(x)); if (sizeof ((void) sizeof(char[1 - 2 * x]))) { register const ; extern void; ; asm("" : "=a"(x), "=d"(x) : "r" (x), "0" (x), "1" (x)); void; } else { for (unsigned int i = f(); i < .1; i++) { for (unsigned int i = (x == 0); i < &&l; i++) { ; __builtin_inf(); __builtin_alloca(1); alignof(x); ; class s { } ; asm volatile ("" : : : ); ; }; int a[] = {};; x; ; class s { } ; const ; x; ~-1 - 0; }; 0 << 0 >> 0; &f; s; __builtin_constant_p(2); ;; struct s restrict ; struct t: s {} ; }; } class &&l { } ;; } void T( int *x) { f(); } | ^~~ crash1.cc:1:83: error: invalid conversion from 'int' to 'f()::s' [-fpermissive] 1 | constexpr const short f() { return 1.2345 * 0 / 01e9; try { enum s { } a[] = { 0 };; __attribute__ ((noinline(2))); a || -1ULL; } catch (int x) { int a[] = { 0 }; struct s { }; struct t: s {} ; try { (x %= 0); (x == 0); l:; } catch (int x) { auto x = f(); struct s {}; struct l: s {} t; 0 - 0; 0 + 0; } [] ( union s {} ) {};f; (sizeof(x) == __builtin_popcount(x)); if (sizeof ((void) sizeof(char[1 - 2 * x]))) { register const ; extern void; ; asm("" : "=a"(x), "=d"(x) : "r" (x), "0" (x), "1" (x)); void; } else { for (unsigned int i = f(); i < .1; i++) { for (unsigned int i = (x == 0); i < &&l; i++) { ; __builtin_inf(); __builtin_alloca(1); alignof(x); ; class s { } ; asm volatile ("" : : : ); ; }; int a[] = {};; x; ; class s { } ; const ; x; ~-1 - 0; }; 0 << 0 >> 0; &f; s; __builtin_constant_p(2); ;; struct s restrict ; struct t: s {} ; }; } class &&l { } ;; } void T( int *x) { f(); } | ^ | | | int crash1.cc:1:89: warning: attributes at the beginning of statement are ignored [-Wattributes] 1 | constexpr const short f() { return 1.2345 * 0 / 01e9; try { enum s { } a[] = { 0 };; __attribute__ ((noinline(2))); a || -1ULL; } catch (int x) { int a[] = { 0 }; struct s { }; struct t: s {} ; try { (x %= 0); (x == 0); l:; } catch (int x) { auto x = f(); struct s {}; struct l: s {} t; 0 - 0; 0 + 0; } [] ( union s {} ) {};f; (sizeof(x) == __builtin_popcount(x)); if (sizeof ((void) sizeof(char[1 - 2 * x]))) { register const ; extern void; ; asm("" : "=a"(x), "=d"(x) : "r" (x), "0" (x), "1" (x)); void; } else { for (unsigned int i = f(); i < .1; i++) { for (unsigned int i = (x == 0); i < &&l; i++) { ; __builtin_inf(); __builtin_alloca(1); alignof(x); ; class s { } ; asm volatile ("" : : : ); ; }; int a[] = {};; x; ; class s { } ; const ; x; ~-1 - 0; }; 0 << 0 >> 0; &f; s; __builtin_constant_p(2); ;; struct s restrict ; struct t: s {} ; }; } class &&l { } ;; } void T( int *x) { f(); } | ^~~~~~~~~~~~~ crash1.cc:1:199: warning: 'try' in 'constexpr' function only available with '-std=c++2a' or '-std=gnu++2a' 1 | constexpr const short f() { return 1.2345 * 0 / 01e9; try { enum s { } a[] = { 0 };; __attribute__ ((noinline(2))); a || -1ULL; } catch (int x) { int a[] = { 0 }; struct s { }; struct t: s {} ; try { (x %= 0); (x == 0); l:; } catch (int x) { auto x = f(); struct s {}; struct l: s {} t; 0 - 0; 0 + 0; } [] ( union s {} ) {};f; (sizeof(x) == __builtin_popcount(x)); if (sizeof ((void) sizeof(char[1 - 2 * x]))) { register const ; extern void; ; asm("" : "=a"(x), "=d"(x) : "r" (x), "0" (x), "1" (x)); void; } else { for (unsigned int i = f(); i < .1; i++) { for (unsigned int i = (x == 0); i < &&l; i++) { ; __builtin_inf(); __builtin_alloca(1); alignof(x); ; class s { } ; asm volatile ("" : : : ); ; }; int a[] = {};; x; ; class s { } ; const ; x; ~-1 - 0; }; 0 << 0 >> 0; &f; s; __builtin_constant_p(2); ;; struct s restrict ; struct t: s {} ; }; } class &&l { } ;; } void T( int *x) { f(); } | ^~~ crash1.cc:1:208: warning: division by zero [-Wdiv-by-zero] 1 | constexpr const short f() { return 1.2345 * 0 / 01e9; try { enum s { } a[] = { 0 };; __attribute__ ((noinline(2))); a || -1ULL; } catch (int x) { int a[] = { 0 }; struct s { }; struct t: s {} ; try { (x %= 0); (x == 0); l:; } catch (int x) { auto x = f(); struct s {}; struct l: s {} t; 0 - 0; 0 + 0; } [] ( union s {} ) {};f; (sizeof(x) == __builtin_popcount(x)); if (sizeof ((void) sizeof(char[1 - 2 * x]))) { register const ; extern void; ; asm("" : "=a"(x), "=d"(x) : "r" (x), "0" (x), "1" (x)); void; } else { for (unsigned int i = f(); i < .1; i++) { for (unsigned int i = (x == 0); i < &&l; i++) { ; __builtin_inf(); __builtin_alloca(1); alignof(x); ; class s { } ; asm volatile ("" : : : ); ; }; int a[] = {};; x; ; class s { } ; const ; x; ~-1 - 0; }; 0 << 0 >> 0; &f; s; __builtin_constant_p(2); ;; struct s restrict ; struct t: s {} ; }; } class &&l { } ;; } void T( int *x) { f(); } | ~~^~~~ crash1.cc:1:252: error: redeclaration of 'auto x' [-fpermissive] 1 | n 1.2345 * 0 / 01e9; try { enum s { } a[] = { 0 };; __attribute__ ((noinline(2))); a || -1ULL; } catch (int x) { int a[] = { 0 }; struct s { }; struct t: s {} ; try { (x %= 0); (x == 0); l:; } catch (int x) { auto x = f(); struct s {}; struct l: s {} t; 0 - 0; 0 + 0; } [] ( union s {} ) {};f; (sizeof(x) == __builtin_popcount(x)); if (sizeof ((void) sizeof(char[1 - 2 * x]))) { register const ; extern void; ; asm("" : "=a"(x), "=d"(x) : "r" (x), "0" (x), "1" (x)); void; } else { for (unsigned int i = f(); i < .1; i++) { for (unsigned int i = (x == 0); i < &&l; i++) { ; __builtin_inf(); __builtin_alloca(1); alignof(x); ; class s { } ; asm volatile ("" : : : ); ; }; int a[] = {};; x; ; class s { } ; const ; x; ~-1 - 0; }; 0 << 0 >> 0; &f; s; __builtin_constant_p(2); ;; struct s restrict ; struct t: s {} ; }; } class &&l { } ;; } void T( int *x) { f(); } | ^ crash1.cc:1:242: note: 'int x' previously declared here 1 | () { return 1.2345 * 0 / 01e9; try { enum s { } a[] = { 0 };; __attribute__ ((noinline(2))); a || -1ULL; } catch (int x) { int a[] = { 0 }; struct s { }; struct t: s {} ; try { (x %= 0); (x == 0); l:; } catch (int x) { auto x = f(); struct s {}; struct l: s {} t; 0 - 0; 0 + 0; } [] ( union s {} ) {};f; (sizeof(x) == __builtin_popcount(x)); if (sizeof ((void) sizeof(char[1 - 2 * x]))) { register const ; extern void; ; asm("" : "=a"(x), "=d"(x) : "r" (x), "0" (x), "1" (x)); void; } else { for (unsigned int i = f(); i < .1; i++) { for (unsigned int i = (x == 0); i < &&l; i++) { ; __builtin_inf(); __builtin_alloca(1); alignof(x); ; class s { } ; asm volatile ("" : : : ); ; }; int a[] = {};; x; ; class s { } ; const ; x; ~-1 - 0; }; 0 << 0 >> 0; &f; s; __builtin_constant_p(2); ;; struct s restrict ; struct t: s {} ; }; } class &&l { } ;; } void T( int *x) { f(); } | ^ crash1.cc:1:322: error: types may not be defined in parameter types 1 | (noinline(2))); a || -1ULL; } catch (int x) { int a[] = { 0 }; struct s { }; struct t: s {} ; try { (x %= 0); (x == 0); l:; } catch (int x) { auto x = f(); struct s {}; struct l: s {} t; 0 - 0; 0 + 0; } [] ( union s {} ) {};f; (sizeof(x) == __builtin_popcount(x)); if (sizeof ((void) sizeof(char[1 - 2 * x]))) { register const ; extern void; ; asm("" : "=a"(x), "=d"(x) : "r" (x), "0" (x), "1" (x)); void; } else { for (unsigned int i = f(); i < .1; i++) { for (unsigned int i = (x == 0); i < &&l; i++) { ; __builtin_inf(); __builtin_alloca(1); alignof(x); ; class s { } ; asm volatile ("" : : : ); ; }; int a[] = {};; x; ; class s { } ; const ; x; ~-1 - 0; }; 0 << 0 >> 0; &f; s; __builtin_constant_p(2); ;; struct s restrict ; struct t: s {} ; }; } class &&l { } ;; } void T( int *x) { f(); } | ^ g++-10: internal compiler error: Segmentation fault signal terminated program cc1plus Please submit a full bug report, with preprocessed source if appropriate. See <file:///usr/share/doc/gcc-10/README.Bugs> for instructions. --- g++-10 crash log ends ---
next reply other threads:[~2021-02-05 3:38 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-02-05 3:38 zhan3299 at purdue dot edu [this message] 2021-02-05 8:12 ` [Bug c++/98972] " marxin at gcc dot gnu.org 2021-02-05 13:36 ` zhan3299 at purdue dot edu 2021-02-05 13:43 ` marxin at gcc dot gnu.org 2021-02-05 16:31 ` zhan3299 at purdue dot edu 2021-02-05 16:44 ` mpolacek at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-98972-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).