Bug 28450 - [4.0 regression] ICE with new and complex/vector types
Summary: [4.0 regression] ICE with new and complex/vector types
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P2 normal
Target Milestone: 4.0.4
Assignee: Andrew Pinski
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ice-on-valid-code, monitored, patch
Depends on:
Blocks:
 
Reported: 2006-07-21 13:20 UTC by Volker Reichelt
Modified: 2006-10-11 03:12 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-08-18 03:54:40


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2006-07-21 13:20:44 UTC
Each of the following lines triggers an ICE since GCC 3.3:

=======================================================
void* p = new __complex__ int ();
void* q = new int __attribute__((vector_size(8))) ();
=======================================================

bug.cc:1: internal compiler error: in build_zero_init, at cp/init.c:252
Please submit a full bug report, [etc.]

This is because build_zero_init doesn't handle COMPLEX_TYPE and VECTOR_TYPE.
Before GCC 3.3 the code was rejected.
Comment 1 Andrew Pinski 2006-07-26 00:27:21 UTC
This is valid with extension rule.  We should produce an empty CONSTRUCTOR for these two cases.  If I get time this weekend I will look more into this.
Comment 2 Andrew Pinski 2006-08-18 03:54:40 UTC
Here is a patch (though I have looked to see if it works with templates yet):
Index: init.c
===================================================================
--- init.c      (revision 116236)
+++ init.c      (working copy)
@@ -178,7 +178,8 @@ build_zero_init (tree type, tree nelts,
        items with static storage duration that are not otherwise
        initialized are initialized to zero.  */
     ;
-  else if (SCALAR_TYPE_P (type))
+  else if (SCALAR_TYPE_P (type)
+          || TREE_CODE (type) == COMPLEX_TYPE)
     init = convert (type, integer_zero_node);
   else if (CLASS_TYPE_P (type))
     {
@@ -248,6 +249,8 @@ build_zero_init (tree type, tree nelts,
       /* Build a constructor to contain the initializations.  */
       init = build_constructor (type, v);
     }
+  else if (TREE_CODE (type) == VECTOR_TYPE)
+    init = fold_convert (type, integer_zero_node);
   else
     gcc_assert (TREE_CODE (type) == REFERENCE_TYPE);

Comment 3 Andrew Pinski 2006-08-18 04:02:14 UTC
Mine.
Comment 4 patchapp@dberlin.org 2006-08-22 15:43:28 UTC
Subject: Bug number PR C++/28450

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-08/msg00793.html
Comment 5 Andrew Pinski 2006-08-23 02:57:25 UTC
Subject: Bug 28450

Author: pinskia
Date: Wed Aug 23 02:56:43 2006
New Revision: 116341

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116341
Log:
2006-08-21  Andrew Pinski  <pinskia@physics.uc.edu>

        PR C++/28450
        * cp/init.c (build_zero_init): Handle VECTOR_TYPE and
        COMPLEX_TYPEs.


2006-08-21  Andrew Pinski  <pinskia@physics.uc.edu>

        PR C++/28450
        * g++.dg/ext/vector4.C: New test.
        * g++.dg/ext/complex1.C: New test.



Added:
    trunk/gcc/testsuite/g++.dg/ext/complex1.C
    trunk/gcc/testsuite/g++.dg/ext/vector4.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/init.c
    trunk/gcc/testsuite/ChangeLog

Comment 6 Andrew Pinski 2006-08-23 02:59:35 UTC
Fixed on the mainline, will apply to the branches after a week.
Comment 7 Andrew Pinski 2006-10-06 13:07:13 UTC
Subject: Bug 28450

Author: pinskia
Date: Fri Oct  6 13:06:56 2006
New Revision: 117502

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117502
Log:
2006-10-06  Andrew Pinski  <pinskia@physics.uc.edu>

        PR C++/28450
        * cp/init.c (build_zero_init): Handle VECTOR_TYPE and
        COMPLEX_TYPEs.

2006-10-06  Andrew Pinski  <pinskia@physics.uc.edu>

        PR C++/28450
        * g++.dg/ext/vector4.C: New test.
        * g++.dg/ext/complex1.C: New test.



Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/ext/complex1.C
      - copied unchanged from r116341, trunk/gcc/testsuite/g++.dg/ext/complex1.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/ext/vector4.C
      - copied unchanged from r116341, trunk/gcc/testsuite/g++.dg/ext/vector4.C
Modified:
    branches/gcc-4_1-branch/gcc/cp/ChangeLog
    branches/gcc-4_1-branch/gcc/cp/init.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 8 Andrew Pinski 2006-10-06 13:09:26 UTC
Fixed also on the 4.1 branch.
Comment 9 Andrew Pinski 2006-10-11 03:10:35 UTC
Subject: Bug 28450

Author: pinskia
Date: Wed Oct 11 03:10:25 2006
New Revision: 117627

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117627
Log:
2006-10-10  Andrew Pinski  <pinskia@physics.uc.edu>

        PR C++/28450
        * cp/init.c (build_zero_init): Handle VECTOR_TYPE and
        COMPLEX_TYPEs.

2006-10-10  Andrew Pinski  <pinskia@physics.uc.edu>

        PR C++/28450
        * g++.dg/ext/vector4.C: New test.
        * g++.dg/ext/complex1.C: New test.



Added:
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/ext/complex1.C
      - copied unchanged from r116341, trunk/gcc/testsuite/g++.dg/ext/complex1.C
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/ext/vector4.C
      - copied unchanged from r116341, trunk/gcc/testsuite/g++.dg/ext/vector4.C
Modified:
    branches/gcc-4_0-branch/gcc/cp/ChangeLog
    branches/gcc-4_0-branch/gcc/cp/init.c
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog

Comment 10 Andrew Pinski 2006-10-11 03:12:17 UTC
Fixed.