Bug 34917 - [4.2 regression] ICE with const vector
Summary: [4.2 regression] ICE with const vector
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.0
: P3 blocker
Target Milestone: 4.3.0
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code, monitored
Depends on:
Blocks:
 
Reported: 2008-01-22 00:12 UTC by Volker Reichelt
Modified: 2009-03-31 15:01 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.3.0
Known to fail: 4.2.5
Last reconfirmed: 2008-01-22 09:49:30


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2008-01-22 00:12:26 UTC
The following valid code snippet triggers an ICE since GCC 4.2.0:

=====================================================
const int i __attribute((vector_size(8))) = {};
=====================================================

bug.cc:1: internal compiler error: in start_decl, at cp/decl.c:4130
Please submit a full bug report, [etc.]
Comment 1 Andrew Pinski 2008-01-22 03:53:32 UTC
This is a blocker for me.

Confirmed.
Comment 2 littlestar 2008-01-22 06:01:48 UTC
Confirmed gcc 4.2.2.

test.cc
=====================================================
const int i __attribute((vector_size(8))) = {};
int main(int argc, char **argv)
{
  return 0;
}
=====================================================
test.cc:1: internal compiler error: in start_decl, at cp/decl.c:4018
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 3 Jakub Jelinek 2008-01-22 09:49:29 UTC
Testing a fix.
--- tree.c.jj124        2008-01-22 10:46:20.000000000 +0100
+++ tree.c      2008-01-22 10:46:20.000000000 +0100
@@ -3735,6 +3735,8 @@ build_type_attribute_qual_variant (tree 
 
       ttype = build_qualified_type (ntype, quals);
     }
+  else if (TYPE_QUALS (ttype) != quals)
+    ttype = build_qualified_type (ttype, quals);
 
   return ttype;
 }

build_type_attribute_qual_variant wasn't changing quals to the requested ones
if the attributes are equal.  This seems to only make a difference for vectors,
as build_type_attribute_qual_variant is static in tree.c and only called
by build_type_attribute_variant which will have always equal quals and
make_vector_type.
Comment 4 Jakub Jelinek 2008-01-22 16:18:59 UTC
Subject: Bug 34917

Author: jakub
Date: Tue Jan 22 16:18:14 2008
New Revision: 131726

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131726
Log:
	PR c++/34917
	* tree.c (build_type_attribute_qual_variant): Call
	build_qualified_type if attributes are equal, but quals are not.

	* g++.dg/ext/vector12.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/ext/vector12.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree.c

Comment 5 Jakub Jelinek 2008-01-22 16:20:00 UTC
Fixed on the trunk.
Comment 6 Joseph S. Myers 2008-02-01 16:55:16 UTC
4.2.3 is being released now, changing milestones of open bugs to 4.2.4.
Comment 7 Joseph S. Myers 2008-05-19 20:24:38 UTC
4.2.4 is being released, changing milestones to 4.2.5.
Comment 8 Joseph S. Myers 2009-03-31 15:01:07 UTC
Closing 4.2 branch, fixed in 4.3.