From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DD64839DE078; Fri, 5 Feb 2021 03:38:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DD64839DE078 From: "zhan3299 at purdue dot edu" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: zhan3299 at purdue dot edu X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Feb 2021 03:38:04 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98972 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,=20 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= [] =3D { 0 };; __attribute__ ((noinline(2))); a || -1ULL; } catch (int x) { int a[= ] =3D { 0 }; struct s { }; struct t: s {} ; try { (x %=3D 0); (x =3D=3D 0); l:; = } catch (int x) { auto x =3D f(); struct s {}; struct l: s {} t; 0 - 0; 0 + 0; } [= ] ( union s {} ) {};f; (sizeof(x) =3D=3D __builtin_popcount(x)); if (sizeof ((v= oid) sizeof(char[1 - 2 * x]))) { register const ; extern void; ; asm("" : "=3Da"= (x), "=3Dd"(x) : "r" (x), "0" (x), "1" (x)); void; } else { for (unsigned int i= =3D f(); i < .1; i++) { for (unsigned int i =3D (x =3D=3D 0); i < &&l; i++) { ; __builtin_inf(); __builtin_alloca(1); alignof(x); ; class s { } ; asm volatile ("" : : : ); ; }; int a[] =3D {};; 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=3Dc++2a' or '-std=3Dgnu++2a' 1 | constexpr const short f() { return 1.2345 * 0 / 01e9; try { enum s= {=20 } a[] =3D { 0 };; __attribute__ ((noinline(2))); a || -1ULL; } catch (int = x) { int a[] =3D { 0 }; struct s { }; struct t: s {} ; try { (x %=3D 0); (x =3D= =3D 0); l:; } catch (int x) { auto x =3D f(); struct s {}; struct l: s {} t; 0 - 0; 0 = + 0; } [] ( union s {} ) {};f; (sizeof(x) =3D=3D __builtin_popcount(x)); if (sizeof ((void) sizeof(char[1 - 2 * x]))) { register const ; extern void; ; asm("" : "=3Da"(x), "=3Dd"(x) : "r" (x), "0" (x), "1" (x)); void; } else { for (uns= igned int i =3D f(); i < .1; i++) { for (unsigned int i =3D (x =3D=3D 0); i < &&l= ; i++) { ; __builtin_inf(); __builtin_alloca(1); alignof(x); ; class s { } ; asm volatile ("" : : : ); ; }; int a[] =3D {};; 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' [-fpermiss= ive] 1 | constexpr const short f() { return 1.2345 * 0 / 01e9; try { enum s= {=20 } a[] =3D { 0 };; __attribute__ ((noinline(2))); a || -1ULL; } catch (int = x) { int a[] =3D { 0 }; struct s { }; struct t: s {} ; try { (x %=3D 0); (x =3D= =3D 0); l:; } catch (int x) { auto x =3D f(); struct s {}; struct l: s {} t; 0 - 0; 0 = + 0; } [] ( union s {} ) {};f; (sizeof(x) =3D=3D __builtin_popcount(x)); if (sizeof ((void) sizeof(char[1 - 2 * x]))) { register const ; extern void; ; asm("" : "=3Da"(x), "=3Dd"(x) : "r" (x), "0" (x), "1" (x)); void; } else { for (uns= igned int i =3D f(); i < .1; i++) { for (unsigned int i =3D (x =3D=3D 0); i < &&l= ; i++) { ; __builtin_inf(); __builtin_alloca(1); alignof(x); ; class s { } ; asm volatile ("" : : : ); ; }; int a[] =3D {};; 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(); } |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ^ |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 int crash1.cc:1:89: warning: attributes at the beginning of statement are ignor= ed [-Wattributes] 1 | constexpr const short f() { return 1.2345 * 0 / 01e9; try { enum s= {=20 } a[] =3D { 0 };; __attribute__ ((noinline(2))); a || -1ULL; } catch (int = x) { int a[] =3D { 0 }; struct s { }; struct t: s {} ; try { (x %=3D 0); (x =3D= =3D 0); l:; } catch (int x) { auto x =3D f(); struct s {}; struct l: s {} t; 0 - 0; 0 = + 0; } [] ( union s {} ) {};f; (sizeof(x) =3D=3D __builtin_popcount(x)); if (sizeof ((void) sizeof(char[1 - 2 * x]))) { register const ; extern void; ; asm("" : "=3Da"(x), "=3Dd"(x) : "r" (x), "0" (x), "1" (x)); void; } else { for (uns= igned int i =3D f(); i < .1; i++) { for (unsigned int i =3D (x =3D=3D 0); i < &&l= ; i++) { ; __builtin_inf(); __builtin_alloca(1); alignof(x); ; class s { } ; asm volatile ("" : : : ); ; }; int a[] =3D {};; 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(); } |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ^~~~~~~~~~~~~ crash1.cc:1:199: warning: 'try' in 'constexpr' function only available with '-std=3Dc++2a' or '-std=3Dgnu++2a' 1 | constexpr const short f() { return 1.2345 * 0 / 01e9; try { enum s= {=20 } a[] =3D { 0 };; __attribute__ ((noinline(2))); a || -1ULL; } catch (int = x) { int a[] =3D { 0 }; struct s { }; struct t: s {} ; try { (x %=3D 0); (x =3D= =3D 0); l:; } catch (int x) { auto x =3D f(); struct s {}; struct l: s {} t; 0 - 0; 0 = + 0; } [] ( union s {} ) {};f; (sizeof(x) =3D=3D __builtin_popcount(x)); if (sizeof ((void) sizeof(char[1 - 2 * x]))) { register const ; extern void; ; asm("" : "=3Da"(x), "=3Dd"(x) : "r" (x), "0" (x), "1" (x)); void; } else { for (uns= igned int i =3D f(); i < .1; i++) { for (unsigned int i =3D (x =3D=3D 0); i < &&l= ; i++) { ; __builtin_inf(); __builtin_alloca(1); alignof(x); ; class s { } ; asm volatile ("" : : : ); ; }; int a[] =3D {};; 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(); } |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20 ^~~ crash1.cc:1:208: warning: division by zero [-Wdiv-by-zero] 1 | constexpr const short f() { return 1.2345 * 0 / 01e9; try { enum s= {=20 } a[] =3D { 0 };; __attribute__ ((noinline(2))); a || -1ULL; } catch (int = x) { int a[] =3D { 0 }; struct s { }; struct t: s {} ; try { (x %=3D 0); (x =3D= =3D 0); l:; } catch (int x) { auto x =3D f(); struct s {}; struct l: s {} t; 0 - 0; 0 = + 0; } [] ( union s {} ) {};f; (sizeof(x) =3D=3D __builtin_popcount(x)); if (sizeof ((void) sizeof(char[1 - 2 * x]))) { register const ; extern void; ; asm("" : "=3Da"(x), "=3Dd"(x) : "r" (x), "0" (x), "1" (x)); void; } else { for (uns= igned int i =3D f(); i < .1; i++) { for (unsigned int i =3D (x =3D=3D 0); i < &&l= ; i++) { ; __builtin_inf(); __builtin_alloca(1); alignof(x); ; class s { } ; asm volatile ("" : : : ); ; }; int a[] =3D {};; 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(); } |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20 ~~^~~~ crash1.cc:1:252: error: redeclaration of 'auto x' [-fpermissive] 1 | n 1.2345 * 0 / 01e9; try { enum s { } a[] =3D { 0 };; __attribut= e__ ((noinline(2))); a || -1ULL; } catch (int x) { int a[] =3D { 0 }; struct s = { }; struct t: s {} ; try { (x %=3D 0); (x =3D=3D 0); l:; } catch (int x) { auto= x =3D f();=20 struct s {}; struct l: s {} t; 0 - 0; 0 + 0; } [] ( union s {} ) {};f; (sizeof(x) =3D=3D __builtin_popcount(x)); if (sizeof ((void) sizeof(char[1 = - 2 * x]))) { register const ; extern void; ; asm("" : "=3Da"(x), "=3Dd"(x) : "r"= (x), "0" (x), "1" (x)); void; } else { for (unsigned int i =3D f(); i < .1; i++= ) { for (unsigned int i =3D (x =3D=3D 0); i < &&l; i++) { ; __builtin_inf(); __builtin_alloca(1); alignof(x); ; class s { } ; asm volatile ("" : : := ); ; }; int a[] =3D {};; x; ; class s { } ; const ; x; ~-1 - 0; }; 0 << 0 >>= 0; &f; s; __builtin_constant_p(2); ;; struct s restrict ; struct t: s {} ; };= }=20 class &&l { } ;; } void T( int *x) { f(); } |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20 ^ crash1.cc:1:242: note: 'int x' previously declared here 1 | () { return 1.2345 * 0 / 01e9; try { enum s { } a[] =3D { 0 };; __attribute__ ((noinline(2))); a || -1ULL; } catch (int x) { int a[] =3D { = 0 }; struct s { }; struct t: s {} ; try { (x %=3D 0); (x =3D=3D 0); l:; } catch= (int x) { auto x =3D f(); struct s {}; struct l: s {} t; 0 - 0; 0 + 0; } [] ( union = s {} ) {};f; (sizeof(x) =3D=3D __builtin_popcount(x)); if (sizeof ((void) sizeof(c= har[1 - 2 * x]))) { register const ; extern void; ; asm("" : "=3Da"(x), "=3Dd"(x) := "r" (x), "0" (x), "1" (x)); void; } else { for (unsigned int i =3D f(); i < .1= ; i++) { for (unsigned int i =3D (x =3D=3D 0); i < &&l; i++) { ; __builtin_inf(); __builtin_alloca(1); alignof(x); ; class s { } ; asm volatile ("" : : := ); ; }; int a[] =3D {};; x; ; class s { } ; const ; x; ~-1 - 0; }; 0 << 0 >>= 0; &f; s; __builtin_constant_p(2); ;; struct s restrict ; struct t: s {} ; };= }=20 class &&l { } ;; } void T( int *x) { f(); } |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20 ^ crash1.cc:1:322: error: types may not be defined in parameter types 1 | (noinline(2))); a || -1ULL; } catch (int x) { int a[] =3D { 0 }; st= ruct s { }; struct t: s {} ; try { (x %=3D 0); (x =3D=3D 0); l:; } catch (int x) = { auto x =3D f(); struct s {}; struct l: s {} t; 0 - 0; 0 + 0; } [] ( union s {} ) {};f; (sizeof(x) =3D=3D __builtin_popcount(x)); if (sizeof ((void) sizeof(char[1 = - 2 * x]))) { register const ; extern void; ; asm("" : "=3Da"(x), "=3Dd"(x) : "r"= (x), "0" (x), "1" (x)); void; } else { for (unsigned int i =3D f(); i < .1; i++= ) { for (unsigned int i =3D (x =3D=3D 0); i < &&l; i++) { ; __builtin_inf(); __builtin_alloca(1); alignof(x); ; class s { } ; asm volatile ("" : : := ); ; }; int a[] =3D {};; x; ; class s { } ; const ; x; ~-1 - 0; }; 0 << 0 >>= 0; &f; s; __builtin_constant_p(2); ;; struct s restrict ; struct t: s {} ; };= }=20 class &&l { } ;; } void T( int *x) { f(); } |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20 ^ g++-10: internal compiler error: Segmentation fault signal terminated progr= am cc1plus Please submit a full bug report, with preprocessed source if appropriate. See for instructions. --- g++-10 crash log ends ---=