Bug 17431 - [3.4 regression] Internal error: Segmentation fault (program cc1plus)
Summary: [3.4 regression] Internal error: Segmentation fault (program cc1plus)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.2
: P1 critical
Target Milestone: 3.4.4
Assignee: Nathan Sidwell
URL:
Keywords: ice-on-invalid-code
: 18677 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-09-12 05:52 UTC by yoav.frandzel
Modified: 2004-12-01 12:58 UTC (History)
5 users (show)

See Also:
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 (105.38 KB, application/octet-stream)
2004-09-12 06:00 UTC, yoav.frandzel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description yoav.frandzel 2004-09-12 05:52:44 UTC
I can send in the .ii file upon request.
Other relevant information follows.

uname -a:
Linux itstl106 2.4.9-45lxset11smp #1 SMP Mon Jan 5 17:01:11 MST 2004 i686 
unknown

g++ -v:
Configured with: ./configure --prefix=/nfs/iil/iec/sws/work/yoavf/tmp : 
(reconfigured) ./configure --prefix=/nfs/iil/iec/sws/work/yoavf/tmp --with-
ld=/nfs/iil/iec/sws/work/yoavf/tmp/bin/ld --with-
as=/nfs/iil/iec/sws/work/yoavf/tmp/bin/as
Thread model: posix
gcc version 3.4.2
(using binutils version 2.15

The command line:
/nfs/iil/iec/sws/work/yoavf/tmp/bin/g++ --save-temps -O3  -c -DLinux -D_Linux -
I. -idirafter /usr/afsws/include -I/usr/intel/pkgs/java/1.3.0/include -
I/usr/intel/pkgs/java/1.3.0/include/linux -I../../../../common/cpp  -
I../../../../common/cpp -DNSC_DEBUG -DVERSION='"netbatch release 6.4.0_0125"' -
o ../obj/Linux_2.4_i686/netbatch/cpp/nb_commands/NBSTAT/../../../../common/cpp/
ccommand/CCommand.o ../../../../common/cpp/ccommand/CCommand.cpp


The error displayed:
g++: Internal error: Segmentation fault (program cc1plus)
Please submit a full bug report.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Andrew Pinski 2004-09-12 05:59:16 UTC
Can you attach the .ii to the URL below?
Comment 2 yoav.frandzel 2004-09-12 06:00:56 UTC
Created attachment 7104 [details]
.ii file

*.ii attached
Comment 3 yoav.frandzel 2004-09-12 06:02:23 UTC
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?

Comment 4 Volker Reichelt 2004-09-12 10:16:47 UTC
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.
Comment 5 Volker Reichelt 2004-09-12 11:28:12 UTC
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);
 
 
=======================================================================
Comment 6 Volker Reichelt 2004-09-12 11:38:09 UTC
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?
Comment 7 Volker Reichelt 2004-09-12 18:40:58 UTC
This is related to PR 5247 where we also run into an infinite
loop looking up a suitable constructor.
Comment 8 Nathan Sidwell 2004-09-14 17:40:16 UTC
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.
Comment 9 Mark Mitchell 2004-11-01 00:44:44 UTC
Postponed until GCC 3.4.4.
Comment 10 Volker Reichelt 2004-11-26 21:00:47 UTC
*** Bug 18677 has been marked as a duplicate of this bug. ***
Comment 11 Volker Reichelt 2004-11-26 21:10:25 UTC
Here's a slightly shorter testcase (inspired by PR18677):

===================
struct A {};

struct B : A
{
    B(int);
    B(B&);
    B(A);
};

B b=0;
===================
Comment 12 Giovanni Bajo 2004-11-26 22:50:11 UTC
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?
Comment 13 Nathan Sidwell 2004-11-29 11:48:24 UTC
(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
Comment 14 GCC Commits 2004-12-01 10:17:02 UTC
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

Comment 15 Nathan Sidwell 2004-12-01 10:22:17 UTC
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)
Comment 16 Andrew Pinski 2004-12-01 12:36:40 UTC
Fixed on the mainline at least.
Comment 17 Nathan Sidwell 2004-12-01 12:58:02 UTC
fixed on 3.4 branch too
Comment 18 GCC Commits 2004-12-01 13:02:00 UTC
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

Comment 19 Mark Mitchell 2004-12-01 15:08:34 UTC
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.