Bug 22604 - [4.0/4.1 Regression] ICE after invalid covariant return
Summary: [4.0/4.1 Regression] ICE after invalid covariant return
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.1
: P2 minor
Target Milestone: 4.0.3
Assignee: Nathan Sidwell
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: error-recovery, ice-on-invalid-code, monitored, patch
Depends on:
Blocks:
 
Reported: 2005-07-22 03:37 UTC by Flash Sheridan
Modified: 2005-10-18 12:40 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-10-13 21:01:00


Attachments
BBinder_segfault.ii (100 bytes, text/plain)
2005-07-22 03:38 UTC, Flash Sheridan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Flash Sheridan 2005-07-22 03:37:16 UTC
The invalid code below results in "internal compiler error: Segmentation fault" 
with a checking version of GCC 4.0.1.  Does not happen with GCC 3.3.4 or Apple GCC 4.0.0.
Like the code for bug 22603, this is a greatly-reduced and anonymized excerpt, found by Daniel 
Wilkerson's Delta, from a real PalmSource file.  (This reduction was found by looking for a segfault; the 
previous reduction looked for any compiler error.)  
    I don't think this is the same bug as my 22508, since that one also happened with Apple GCC 4.0.0.  
It doesn't sound to me like 21975 or 22441 either.


class NameOne;
class NameTwo : virtual public SAtom
{
 virtual NameOne* NameThree();
};
class NameFour : virtual public NameFive
{
class NameOne : public NameTwo
{
  virtual NameOne* NameThree();



======
Session:
125> /opt/gcc401chk/bin/g++ -v  /Projects/PlatformTools/compilerChain/tests/cpp/bugfiles/error/
BBinder_segfault.ii
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../configure --enable-checking --prefix=/opt/gcc401chk --enable-languages=c,c+
+
Thread model: posix
gcc version 4.0.1
 /opt/gcc401chk/libexec/gcc/i686-pc-linux-gnu/4.0.1/cc1plus -fpreprocessed /Projects/
PlatformTools/compilerChain/tests/cpp/bugfiles/error/BBinder_segfault.ii -quiet -dumpbase 
BBinder_segfault.ii -mtune=pentiumpro -auxbase BBinder_segfault -version -o /tmp/ccuEkHiJ.s
GNU C++ version 4.0.1 (i686-pc-linux-gnu)
        compiled by GNU C version 3.3.4 (pre 3.3.5 20040809).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
/Projects/PlatformTools/compilerChain/tests/cpp/bugfiles/error/BBinder_segfault.ii:3: error: expected 
class-name before ‘{’ token
/Projects/PlatformTools/compilerChain/tests/cpp/bugfiles/error/BBinder_segfault.ii:7: error: expected 
class-name before ‘{’ token
/Projects/PlatformTools/compilerChain/tests/cpp/bugfiles/error/BBinder_segfault.ii:10: error: 
expected `}' at end of input
/Projects/PlatformTools/compilerChain/tests/cpp/bugfiles/error/BBinder_segfault.ii:10: error: invalid 
covariant return type for ‘virtual NameFour::NameOne* NameFour::NameOne::NameThree()’
/Projects/PlatformTools/compilerChain/tests/cpp/bugfiles/error/BBinder_segfault.ii:4: error:   
overriding ‘virtual NameOne* NameTwo::NameThree()’
/Projects/PlatformTools/compilerChain/tests/cpp/bugfiles/error/BBinder_segfault.ii:9: internal 
compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

Like bug 22603, this is tracked by PalmSouce bug 104911, though I suspect it's different.
Comment 1 Flash Sheridan 2005-07-22 03:38:13 UTC
Created attachment 9327 [details]
BBinder_segfault.ii
Comment 2 Andrew Pinski 2005-07-22 03:53:06 UTC
Confirmed.
Here is the backtrace:
#0  0x080b94b6 in dfs_modify_vtables (binfo=0xb7d11840, data=0xb7cbe398) at /home/peshtigo/
pinskia/src/gnu/gcc/src/gcc/cp/class.c:2032
#1  0x08122b40 in dfs_walk_all (binfo=0xb7d11840, pre_fn=0x80b8e00 <dfs_modify_vtables>, 
post_fn=0, data=0xb7cbe398)
    at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/cp/search.c:1528
#2  0x08123444 in dfs_walk_once (binfo=0xb7d11840, pre_fn=0x80b8e00 <dfs_modify_vtables>, 
post_fn=0, data=0xb7cbe398)
    at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/cp/search.c:1651
#3  0x080c8247 in finish_struct_1 (t=0xb7cbe398) at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/
cp/class.c:2223
#4  0x080ca5e6 in finish_struct (t=0xb7cbe398, attributes=0xb7cbe398) at /home/peshtigo/pinskia/
src/gnu/gcc/src/gcc/cp/class.c:5107
#5  0x080e953a in cp_parser_type_specifier (parser=0xb7cbbe38, flags=Variable "flags" is not 
available.
) at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/cp/parser.c:12642
Comment 3 Andrew Pinski 2005-07-22 03:58:55 UTC
I should mention this started to happen after 20041124 but before 20050225.
Comment 4 Serge Belyshev 2005-07-22 08:08:54 UTC
Introduced between "2005-02-14 00:20 UTC" and "2005-02-15 00:20 UTC"
Comment 5 Volker Reichelt 2005-07-25 13:11:56 UTC
Here's an example that only contains one error:

==============================================
struct A;

struct B
{
    virtual A* foo();
};

namespace N
{
    struct A : B
    {
        virtual A* foo(); // should be ::A*
    };
}
==============================================
Comment 6 Flash Sheridan 2005-07-28 03:15:56 UTC
Here's another segfault, originally PalmSource bug 105158, but after Delta reduction it looked similar:

class nameOne : public nameTwo, public nameThree, public nameFour, public nameFive, public nameSix
{
 void nameSeven(const nameEight &name, const nameNine & icon);
 virtual void nameSeven(const nameEight& name, const nameTen &icon);
Comment 7 Andrew Pinski 2005-07-28 03:27:20 UTC
(In reply to comment #6)
> Here's another segfault, originally PalmSource bug 105158, but after Delta reduction it looked 
similar:

That is a different issue, please file as a seperate bug.
Comment 8 Volker Reichelt 2005-08-05 15:28:08 UTC
For the record: The bug from comment #6 is tracked in PR23118.
Comment 9 Volker Reichelt 2005-08-05 15:43:43 UTC
Testing a patch.
Comment 10 Andrew Pinski 2005-08-08 18:13:46 UTC
This worked with 20041211.
Comment 11 Flash Sheridan 2005-08-12 01:26:38 UTC
The patch looks good.  A checking=yes build, with patches 20161-8277, 22508-2005-08-00326, 
22600-9330, and 22604-2005-08-00334, rejected the file BBinder_segfault.ii without an ICE.  (A 
checking=all build is still building.)  A run of  'make check' didn't report any unexpected errors.
Comment 12 Nathan Sidwell 2005-10-17 17:36:09 UTC
I'll take a look
Comment 13 GCC Commits 2005-10-18 12:30:38 UTC
Subject: Bug 22604

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	nathan@gcc.gnu.org	2005-10-18 12:30:33

Modified files:
	gcc/cp         : ChangeLog cp-tree.h class.c semantics.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/overload: error2.C 
	gcc/testsuite/g++.dg/inherit: covariant14.C 

Log message:
	cp:
	PR c++/22604
	* class.c (update_vtable_entry_for_fn): Don't process invalid
	covariant overriders.
	
	PR c++/23118
	* cp-tree.h (add_method): Add return value.
	* class.c (add_method): Return success indicator.
	* semantics.c (finish_member_declaration): Don't add an invalid
	method to the method list.
	testsuite:
	PR c++/23118
	* g++.dg/overload/error2.C: New.
	
	PR c++/22604
	* g++.dg/inherit/covariant14.C: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4944&r2=1.4945
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.1168&r2=1.1169
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&r1=1.737&r2=1.738
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/semantics.c.diff?cvsroot=gcc&r1=1.493&r2=1.494
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6207&r2=1.6208
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/error2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/inherit/covariant14.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 14 GCC Commits 2005-10-18 12:34:35 UTC
Subject: Bug 22604

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	nathan@gcc.gnu.org	2005-10-18 12:34:30

Modified files:
	gcc/cp         : ChangeLog cp-tree.h class.c semantics.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/overload: error2.C 
	gcc/testsuite/g++.dg/inherit: covariant14.C 

Log message:
	cp:
	PR c++/22604
	* class.c (update_vtable_entry_for_fn): Don't process invalid
	covariant overriders.
	
	PR c++/23118
	* cp-tree.h (add_method): Add return value.
	* class.c (add_method): Return success indicator.
	* semantics.c (finish_member_declaration): Don't add an invalid
	method to the method list.
	testsuite:
	PR c++/23118
	* g++.dg/overload/error2.C: New.
	
	PR c++/22604
	* g++.dg/inherit/covariant14.C: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.142&r2=1.4648.2.143
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1106.2.17&r2=1.1106.2.18
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.707.2.8&r2=1.707.2.9
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/semantics.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.463.2.12&r2=1.463.2.13
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.466&r2=1.5084.2.467
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/error2.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/inherit/covariant14.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1

Comment 15 Nathan Sidwell 2005-10-18 12:40:02 UTC
fixed mainline and 4.0
2005-10-18  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/22604
	* class.c (update_vtable_entry_for_fn): Don't process invalid
	covariant overriders.

	PR c++/23118
	* cp-tree.h (add_method): Add return value.
	* class.c (add_method): Return success indicator.
	* semantics.c (finish_member_declaration): Don't add an invalid
	method to the method list.

wont fix 3.4