Summary: | [3.4 regression] Internal error: Segmentation fault (program cc1plus) | ||
---|---|---|---|
Product: | gcc | Reporter: | yoav.frandzel |
Component: | c++ | Assignee: | Nathan Sidwell <nathan> |
Status: | RESOLVED FIXED | ||
Severity: | critical | CC: | debian-gcc, gcc-bugs, mark, nathan, reichelt |
Priority: | P1 | Keywords: | ice-on-invalid-code |
Version: | 3.4.2 | ||
Target Milestone: | 3.4.4 | ||
Host: | Target: | ||
Build: | Known to work: | 3.3.4 3.4.0 4.0.0 | |
Known to fail: | 3.4.1 3.4.2 | Last reconfirmed: | 2004-09-12 11:28:16 |
Attachments: | .ii file |
Description
yoav.frandzel
2004-09-12 05:52:44 UTC
Can you attach the .ii to the URL below? Created attachment 7104 [details]
.ii file
*.ii attached
Subject: RE: Internal error: Segmentation fault (program cc1plus) Done already, I believe. -----Original Message----- From: pinskia at gcc dot gnu dot org [mailto:gcc-bugzilla@gcc.gnu.org] Sent: Sunday, September 12, 2004 8:59 AM To: Frandzel, Yoav Subject: [Bug c++/17431] Internal error: Segmentation fault (program cc1plus) ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-09-12 05:59 ------- Can you attach the .ii to the URL below? The code compiles fine with gcc 3.3.4 using about 50 MB without optimization and 100 MB with -O3. After adding a missing typename the code also compiles with gcc 3.4.0, using about 100 MB with -O3. It crashes however with gcc 3.4.1, 3.4.2 and mainline - consuming more than 1.5 GB even with -O0 before the crash. Given the speed of the memory allocation this looks like an infinite loop in the compiler. It's a regression on the 3.4 branch. Here's a reduced testcase: ========================= struct A {}; struct B : A { B(int); B(B&); B(A); }; void foo(B); void bar() { foo(0); } ========================= The copy ctor B(B&) seems to be responsible for the trouble. Replacing it by B(const B&) cures the problem. Upon closer inspection, the code seems to be invalid, since we really need a copy ctor of the form B(const B&). However, we did not diagnose this before 3.4.1, and the code compiled without trouble. Phils regression hunter states : Search converges between 2004-06-28-3.4 (#11) and 2004-06-29-3.4 (#12). Btw, adding the missing typename and fixing the copy ctor in the original testcase with the following patch makes the code compile with gcc 3.4.1 and later: ======================================================================= --- CCommand.ii 2004-09-12 13:01:48.000000000 +0200 +++ CCommand.ii 2004-09-12 13:02:05.000000000 +0200 @@ -38769,7 +38769,7 @@ void CMap<TKEY,TVALUE>::writeObject(CObj template <class TKEY, class TVALUE> void CMap<TKEY,TVALUE>::put (TKEY key, TVALUE value) { - this->insert (std::map<TKEY,TVALUE>::value_type(key, value)); + this->insert (typename std::map<TKEY,TVALUE>::value_type(key, value)); } # 7 "../../../../common/cpp/ccommand/CMessage.h" 2 # 1 "../../../../common/cpp/serialization/types/CString.h" 1 @@ -38791,7 +38791,7 @@ class CString : public Serializable, pub CString (const char* str); - CString (CString& str); + CString (const CString& str); CString (string str); ======================================================================= Nathan, I suspect your patch for PR 16174 http://gcc.gnu.org/ml/gcc-cvs/2004-06/msg01175.html is responsible for the regression. Could you please have a look? This is related to PR 5247 where we also run into an infinite loop looking up a suitable constructor. Hey, guess what, the test case isn't invalid (or the std does not say what it means). struct B : A { B(int); B(B&); B(A); }; In the call to foo, we have to copy the rvalue temp created by B::B(int) -- this copy & temp can and will be elided, but we must check that it is doable. B::B(B&) can't do this, because it has a non-const reference arg, but, B(A) can do it via A's implicit const-copy constructor. EDG 3.4 rejects this code though, and one of our auto_ptr testcases now compiles, due to such a 'sideways' copy path. I'm clarifying with EDG as to what the intent of the std is. Postponed until GCC 3.4.4. *** Bug 18677 has been marked as a duplicate of this bug. *** Here's a slightly shorter testcase (inspired by PR18677): =================== struct A {}; struct B : A { B(int); B(B&); B(A); }; B b=0; =================== Nathan, even if there is not an official committee position on the correct semantic of this program, is there way to get a patch in to stop cc1plus from segfaulting? (In reply to comment #12) > Nathan, even if there is not an official committee position on the correct > semantic of this program, is there way to get a patch in to stop cc1plus from > segfaulting? TC1 fixed this, and EDG were kind enough to point me at the paper describing the problem. I am working on this Subject: Bug 17431 CVSROOT: /cvs/gcc Module name: gcc Changes by: nathan@gcc.gnu.org 2004-12-01 10:16:51 Modified files: gcc/cp : ChangeLog call.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/overload: arg1.C arg2.C arg3.C arg4.C Log message: cp: PR c++/17431 * call.c (standard_conversion): Add FLAGS parameter. Do not allow derived to base conversion when checking constructor accessibility. (implicit_conversion): Pass FLAGS to standard_conversion. (check_constructir_callable): Disallow conversion functions. testsuite: PR c++/17431 * g++.dg/overload/arg1.C: New. * g++.dg/overload/arg2.C: New. * g++.dg/overload/arg3.C: New. * g++.dg/overload/arg4.C: New. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4506&r2=1.4507 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.520&r2=1.521 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4697&r2=1.4698 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/arg1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/arg2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/arg3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/arg4.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 2004-12-01 Nathan Sidwell <nathan@codesourcery.com> PR c++/17431 * call.c (standard_conversion): Add FLAGS parameter. Do not allow derived to base conversion when checking constructor accessibility. (implicit_conversion): Pass FLAGS to standard_conversion. (check_constructir_callable): Disallow conversion functions. (I was incorrect about this being a TC1 change, it was a change during drafting of the 1998 std) Fixed on the mainline at least. fixed on 3.4 branch too Subject: Bug 17431 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: nathan@gcc.gnu.org 2004-12-01 12:58:18 Modified files: gcc/cp : ChangeLog call.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/overload: arg1.C arg2.C arg3.C arg4.C Log message: cp: PR c++/17431 * call.c (standard_conversion): Add FLAGS parameter. Do not allow derived to base conversion when checking constructor accessibility. (implicit_conversion): Pass FLAGS to standard_conversion. (check_constructir_callable): Disallow conversion functions. testsuite: PR c++/17431 * g++.dg/overload/arg1.C: New. * g++.dg/overload/arg2.C: New. * g++.dg/overload/arg3.C: New. * g++.dg/overload/arg4.C: New. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.179&r2=1.3892.2.180 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.452.2.21&r2=1.452.2.22 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.314&r2=1.3389.2.315 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/arg1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/arg2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/arg3.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/arg4.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 Subject: Re: [3.4/4.0 regression] Internal error: Segmentation fault (program cc1plus) cvs-commit at gcc dot gnu dot org wrote: > ------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-12-01 10:17 ------- > Subject: Bug 17431 Yay! > (implicit_conversion): Pass FLAGS to standard_conversion. > (check_constructir_callable): Disallow conversion functions. Typo in the ChangeLog here. |