Bug 30303 - [4.2 regression] ICE with invalid constructor definition
Summary: [4.2 regression] ICE with invalid constructor definition
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.0
: P4 normal
Target Milestone: 4.2.4
Assignee: Not yet assigned to anyone
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: error-recovery, ice-on-invalid-code, monitored, patch
: 30304 33556 (view as bug list)
Depends on:
Blocks: 30304
  Show dependency treegraph
 
Reported: 2006-12-26 13:28 UTC by Volker Reichelt
Modified: 2008-02-13 07:31 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-12-27 03:35:47


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2006-12-26 13:28:46 UTC
The following invalid code snippet triggers an ICE on mainline and 4.2 branch:

==================================
class A
{
  int i;
};

A::A() { A(); }
==================================

bug.cc:6: error: definition of implicitly-declared 'A::A()'
bug.cc:6: error: declaration of 'A::A()' throws different exceptions
bug.cc:2: error: from previous declaration 'A::A() throw ()'
bug.cc: In constructor 'A::A()':
bug.cc:6: internal compiler error: in finish_function, at cp/decl.c:11162
Please submit a full bug report, [etc.]
Comment 1 Andrew Pinski 2006-12-26 22:22:23 UTC
Confirmed.
Comment 2 Andrew Pinski 2006-12-27 03:35:47 UTC
Mine for the new year:
Index: decl.c
===================================================================
--- decl.c      (revision 120211)
+++ decl.c      (working copy)
@@ -6216,7 +6219,10 @@
               XXX Isn't this done in start_function, too?  */
            revert_static_member_fn (decl);
          if (DECL_ARTIFICIAL (old_decl))
-           error ("definition of implicitly-declared %qD", old_decl);
+           {
+             error ("definition of implicitly-declared %qD", old_decl);
+             return error_mark_node;
+           }
 
          /* Since we've smashed OLD_DECL to its
             DECL_TEMPLATE_RESULT, we must do the same to DECL.  */
Comment 3 Andrew Pinski 2006-12-27 03:36:13 UTC
*** Bug 30304 has been marked as a duplicate of this bug. ***
Comment 4 Andrew Pinski 2007-01-02 02:10:36 UTC
I am testing a slightly different patch which is closer to what the rest of the function does, in that return NULL_TREE instead of error_mark_node.
This fixes the problem still and also removes the error "throws different exceptions" which seems like a good idea.
Comment 5 Dayananda 2007-03-25 14:07:28 UTC
I am unsing the following version:
arm-2006q1-6-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar

I get the same error as said above. I am not sure whether to modify the Code [ there are many files; so painful solution :-( ] . Is there a way I can compile the above without touching the C-Files ?
Which version of gcc should I use ?
Can any one suggest me a solution.

Thanks and Regards,
Dayananda
dayas2003@yahoo.com
+91 98452 59517
Comment 6 Mark Mitchell 2007-05-14 22:27:18 UTC
Will not be fixed in 4.2.0; retargeting at 4.2.1.
Comment 7 Andrew Pinski 2007-08-20 06:18:27 UTC
testing the patch right now
Comment 8 Paolo Carlini 2007-09-23 23:02:33 UTC
Any news? ;)
Comment 9 Paolo Carlini 2007-09-25 23:54:13 UTC
*** Bug 33556 has been marked as a duplicate of this bug. ***
Comment 10 Mark Mitchell 2007-10-09 19:22:07 UTC
Change target milestone to 4.2.3, as 4.2.2 has been released.
Comment 11 Andrew Pinski 2007-10-13 19:44:10 UTC
Testing this patch again to make sure it still works.
Comment 12 Andrew Pinski 2007-10-14 18:15:47 UTC
Subject: Bug 30303

Author: pinskia
Date: Sun Oct 14 18:15:35 2007
New Revision: 129298

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129298
Log:
2007-10-14  Andrew Pinski  <pinskia@gmail.com>

        PR c++/30303
        * decl.c (grokfndecl): Return NULL after the "definition of
        implicitly-declared" error happened.

2007-10-14  Andrew Pinski  <pinskia@gmail.com>

        PR c++/30303
        * g++.dg/other/ctor1.C: New test.
        * g++.dg/other/ctor2.C: New test.
        * g++.dg/other/dtor1.C: New test.


Added:
    trunk/gcc/testsuite/g++.dg/other/ctor1.C
    trunk/gcc/testsuite/g++.dg/other/ctor2.C
    trunk/gcc/testsuite/g++.dg/other/dtor1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/testsuite/ChangeLog

Comment 13 Andrew Pinski 2007-10-14 18:16:11 UTC
Fixed on the trunk.
Comment 14 Andrew Pinski 2008-01-03 17:44:27 UTC
I am not going to be able to get this done for 4.2.x so unassigning.
Comment 15 Joseph S. Myers 2008-02-01 16:53:46 UTC
4.2.3 is being released now, changing milestones of open bugs to 4.2.4.
Comment 16 Volker Reichelt 2008-02-13 07:31:42 UTC
The ICE disappeared on the 4.2 branch. Probably due to

2008-02-12  Jason Merrill  <jason@redhat.com>

	PR c++/33916
	* Revert:
	2006-10-17  Mark Mitchell  <mark@codesourcery.com>
	PR c++/29039
	* typeck2.c (build_functional_cast): Don't zero-initialize
	non-PODs; instead, call their constructors.