Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 5247
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Peter Schmid <schmid@snake.iap.physik.tu-darmstadt.de>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 5247 depends on: Show dependency tree
Show dependency graph
Bug 5247 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2006-10-21 21:32 Opened: 2002-01-02 07:56
The following source p.C causes an ice. g++ consumes all virtual
memory until the process is killed by the kernel. When the second
parameter to the a constructor is removed the code compiles

Release:
3.1 20011229 (experimental)

Environment:
System: Linux kiste 2.4.16 #6 Wed Dec 26 16:44:07 CET 2001 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
SuSE 7.3
glibc 2.2.4
GNU ld version 2.11.90.0.29
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads --enable-languages=c,c++,f77,objc --enable-concept-checks

How-To-Repeat:
Source code p.C
struct a {
   a (int, const a & = 0) { }
};

int main ()
{
  a b (0);
}

g++ -v -W -Wall p.C -W -Wall -save-temps
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads --enable-languages=c,c++,f77,objc --enable-concept-checks
Thread model: posix
gcc version 3.1 20011229 (experimental)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/cpp0 -lang-c++ -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -v -D__GNUC__=3 -D__GNUC_MINOR__=1 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -W -Wall -W -Wall -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ p.C p.ii
GNU CPP version 3.1 20011229 (experimental) (cpplib) (i386 Linux/ELF)
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory "/usr/local/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/g++-v3
 /usr/local/include/g++-v3/i686-pc-linux-gnu
 /usr/local/include/g++-v3/backward
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/cc1plus -fpreprocessed p.ii -quiet -dumpbase p.C -W -Wall -W -Wall -version -o p.s
GNU CPP version 3.1 20011229 (experimental) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.1 20011229 (experimental) (i686-pc-linux-gnu)
 compiled by GNU C version 3.1 20011229 (experimental).
g++: Internal error: Killed (program cc1plus)
Please submit a full bug report.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.

Preprocessed source code p.ii
# 1 "p.C"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "p.C"
struct a {
   a (int, const a & = 0) { }
};

int main ()
{
  a b (0);
}

Unformatted:
 >normally. Compiling p.C crashes all g++ compilers I have access
 >to (gcc 2.95.3, gcc 3.03 anf gcc 3.1).

------- Comment #1 From Kriang Lerdsuwanakij 2002-05-28 07:25 -------
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed.

------- Comment #2 From Nathanael C. Nerode 2003-01-22 22:54 -------
From: Nathanael Nerode <neroden@twcny.rr.com>
To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org,
   schmid@snake.iap.physik.tu-darmstadt.de
Cc:  
Subject: Re: c++/5247: ...
Date: Wed, 22 Jan 2003 22:54:24 -0500

 In 3.4, it doesn't seem to eat up memory; at any rate, it crashes very 
 quickly with a segmentation fault.  Still ICEing though.
 


------- Comment #3 From Wolfgang Bangerth 2003-04-01 20:21 -------
From: Wolfgang Bangerth <bangerth@ices.utexas.edu>
To: Giovanni Bajo <giovannibajo@libero.it>
Cc: gcc-gnats@gcc.gnu.org, <gcc-bugs@gcc.gnu.org>,
   <schmid@snake.iap.physik.tu-darmstadt.de>
Subject: Re: c++/5247: [2003-01-22]ICE on default parameter in constructor
 which is reference to class
Date: Tue, 1 Apr 2003 20:21:26 -0600 (CST)

 > The testcase compiles on my 2.95:
 > 
 > $ g++-2 -v
 > Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-10/specs
 > gcc version 2.95.3-10 (cygwin special)
 > 
 > Can somebody double-check?
 
 It gets into an infinite memory eating loop for me with 2.95.3 20010315 (SuSE).
 
 However, here's some more fodder for bug fixers: with 3.4, the loop is 
 these functions, apparently calling each other in infinite ways (I just 
 killed cc1plus at an arbitrary point, so your stack trace will look 
 differently; at this time, gdb showed me the first ~9000 stack frames, 
 before I had to kill it...)
 
 #0  0x08138b87 in break_out_target_exprs (t=0x4015dae0)
     at cp/tree.c:1509
 #1  0x080548b7 in convert_default_arg (type=0x40199288, arg=0x0, 
     fn=0x40199dec, parmnum=1) at cp/call.c:4416
 #2  0x08054eaf in build_over_call (cand=0x446bf70c, flags=3)
     at cp/call.c:4577
 #3  0x0805416d in convert_like_real (convs=0x40199dec, expr=0x4015dae0, 
     fn=0x0, argnum=0, inner=-1) at cp/call.c:4149
 #4  0x08053dca in convert_like_real (convs=0x446c1654, expr=0x4015dae0, 
     fn=0x0, argnum=0, inner=0) at cp/call.c:4220
 #5  0x0805a321 in initialize_reference (type=0x40199288, expr=0x4015dae0, 
     decl=0x0) at cp/call.c:6132
 #6  0x08113f48 in convert_for_initialization (exp=0x40199288, type=0x0, 
     rhs=0x4015dae0, flags=3, errtype=0x84a0e78 "default argument", 
     fndecl=0x40199dec, parmnum=1) at cp/typeck.c:6202
 #7  0x080548fc in convert_default_arg (type=0x40199288, arg=0x0, 
     fn=0x40199dec, parmnum=1) at cp/call.c:4430
 #8  0x08054eaf in build_over_call (cand=0x446bf6b4, flags=3)
     at cp/call.c:4577
 #9  0x0805416d in convert_like_real (convs=0x40199dec, expr=0x4015dae0, 
     fn=0x0, argnum=0, inner=-1) at cp/call.c:4149
 #10 0x08053dca in convert_like_real (convs=0x446c1528, expr=0x4015dae0, 
     fn=0x0, argnum=0, inner=0) at cp/call.c:4220
 #11 0x0805a321 in initialize_reference (type=0x40199288, expr=0x4015dae0, 
     decl=0x0) at cp/call.c:6132
 #12 0x08113f48 in convert_for_initialization (exp=0x40199288, type=0x0, 
     rhs=0x4015dae0, flags=3, errtype=0x84a0e78 "default argument", 
     fndecl=0x40199dec, parmnum=1) at cp/typeck.c:6202
 #13 0x080548fc in convert_default_arg (type=0x40199288, arg=0x0, 
     fn=0x40199dec, parmnum=1) at cp/call.c:4430
 #14 0x08054eaf in build_over_call (cand=0x446bf65c, flags=3)
     at cp/call.c:4577
 #15 0x0805416d in convert_like_real (convs=0x40199dec, expr=0x4015dae0, 
     fn=0x0, argnum=0, inner=-1) at cp/call.c:4149
 #16 0x08053dca in convert_like_real (convs=0x446c13fc, expr=0x4015dae0, 
     fn=0x0, argnum=0, inner=0) at cp/call.c:4220
 #17 0x0805a321 in initialize_reference (type=0x40199288, expr=0x4015dae0, 
     decl=0x0) at cp/call.c:6132
 #18 0x08113f48 in convert_for_initialization (exp=0x40199288, type=0x0, 
     rhs=0x4015dae0, flags=3, errtype=0x84a0e78 "default argument", 
     fndecl=0x40199dec, parmnum=1) at cp/typeck.c:6202
 #19 0x080548fc in convert_default_arg (type=0x40199288, arg=0x0, 
     fn=0x40199dec, parmnum=1) at cp/call.c:4430
 #20 0x08054eaf in build_over_call (cand=0x446bf604, flags=3)
     at cp/call.c:4577
 #21 0x0805416d in convert_like_real (convs=0x40199dec, expr=0x4015dae0, 
     fn=0x0, argnum=0, inner=-1) at cp/call.c:4149
 #22 0x08053dca in convert_like_real (convs=0x446c12d0, expr=0x4015dae0, 
     fn=0x0, argnum=0, inner=0) at cp/call.c:4220
 #23 0x0805a321 in initialize_reference (type=0x40199288, expr=0x4015dae0, 
     decl=0x0) at cp/call.c:6132
 #24 0x08113f48 in convert_for_initialization (exp=0x40199288, type=0x0, 
     rhs=0x4015dae0, flags=3, errtype=0x84a0e78 "default argument", 
     fndecl=0x40199dec, parmnum=1) at cp/typeck.c:6202
 #25 0x080548fc in convert_default_arg (type=0x40199288, arg=0x0, 
     fn=0x40199dec, parmnum=1) at cp/call.c:4430
 
 
 W.
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:            bangerth@ices.utexas.edu
                                www: http://www.ices.utexas.edu/~bangerth/

------- Comment #4 From Giovanni Bajo 2003-04-02 04:07 -------
From: "Giovanni Bajo" <giovannibajo@libero.it>
To: <gcc-gnats@gcc.gnu.org>,
	<gcc-bugs@gcc.gnu.org>,
	<nobody@gcc.gnu.org>,
	<gcc-prs@gcc.gnu.org>,
	<schmid@snake.iap.physik.tu-darmstadt.de>
Cc: "Wolfgang Bangerth" <bangerth@ices.utexas.edu>
Subject: Re: c++/5247: [2003-01-22]ICE on default parameter in constructor which is reference to class
Date: Wed, 2 Apr 2003 04:07:23 +0200

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p
 r=5247
 
 The testcase compiles on my 2.95:
 
 $ g++-2 -v
 Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-10/specs
 gcc version 2.95.3-10 (cygwin special)
 
 Can somebody double-check? If it really works with 2.95, this is a
 regression and should be flagged as such.
 
 Giovanni Bajo
 


------- Comment #5 From Andrew Pinski 2003-06-02 16:55 -------
On the released version of 2.95.3 (2.95.3 20010315 (release)), I get the
behavior 
discrived here.

------- Comment #6 From Andrew Pinski 2003-07-16 04:01 -------
Still happens on the mainline (20030715).

------- Comment #7 From Volker Reichelt 2003-12-08 02:03 -------
I don't think that the code is valid, since there's no finite
conversion series from int to "a".

------- Comment #8 From Andrew Pinski 2003-12-25 21:20 -------
Closely related to bug 13491.

------- Comment #9 From Andrew Pinski 2003-12-25 21:23 -------
*** Bug 13491 has been marked as a duplicate of this bug. ***

------- Comment #10 From Andrew Pinski 2004-08-05 17:57 -------
*** Bug 15528 has been marked as a duplicate of this bug. ***

------- Comment #11 From Wolfgang Bangerth 2004-08-05 18:02 -------
PR 15528 actually has the nicer testcase, IMHO.  
W. 

------- Comment #12 From Richard Guenther 2005-08-29 10:05 -------
EDG manages to produce

pr5247.C(2): error: no suitable constructor exists to convert from "int" to "a"
     a (int, const a & = 0) { }
                         ^

------- Comment #13 From Andrew Pinski 2005-10-06 22:07 -------
*** Bug 24247 has been marked as a duplicate of this bug. ***

------- Comment #14 From Lucas 2006-03-29 21:14 -------
GCC 3.4.4 on Cygwin actually breaks.  The .ii file looks normal, however, it
seems to be segfaulting...I'll try the testcase with mainline shortly.

$ gcc --version
gcc (GCC) 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)
Copyright (C) 2004 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.

------- Comment #15 From Lucas 2006-04-01 13:07 -------
(In reply to comment #14)
> GCC 3.4.4 on Cygwin actually breaks.  The .ii file looks normal, however, it
> seems to be segfaulting...I'll try the testcase with mainline shortly.
> 
> $ gcc --version
> gcc (GCC) 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)
> Copyright (C) 2004 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.
> 

Mainline (20060401) breaks too...same (silent) segfault

------- Comment #16 From Lucas 2006-04-01 13:11 -------
MSVC8 also manages a sensible error message on the testcase from this bug:
C:\cygwin\home\Lucas>cl /c pr5247.cc
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

pr5247.cc
pr5247.cc(2) : fatal error C1202: recursive type or function dependency context
too complex

C:\cygwin\home\Lucas>

------- Comment #17 From Jason Merrill 2007-10-27 15:19 -------
Subject: Bug 5247

Author: jason
Date: Sat Oct 27 15:19:45 2007
New Revision: 129681

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129681
Log:
        PR c++/5247
        * call.c (convert_default_arg): Detect recursion.

Added:
    trunk/gcc/testsuite/g++.dg/overload/defarg1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c

------- Comment #18 From Andrew Pinski 2007-11-19 05:18 -------
Fixed.

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug