Bug 52467 - ICE: canonical types differ for int [0] and int [0]
Summary: ICE: canonical types differ for int [0] and int [0]
Status: RESOLVED WORKSFORME
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-03 13:44 UTC by Martin Griffin
Modified: 2013-05-04 16:33 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.7.3, 4.8.0, 4.9.0
Known to fail:
Last reconfirmed: 2012-03-05 00:00:00


Attachments
Minimal test case (78 bytes, text/x-c++src)
2012-03-03 13:44 UTC, Martin Griffin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Griffin 2012-03-03 13:44:55 UTC
Created attachment 26815 [details]
Minimal test case

I'm not sure if an array of 0 elements is actually legal, but I get an ICE compiling the attached test case:

$ g++ array-0.cpp 
array-0.cpp:6:6: internal compiler error: canonical types differ for identical types int [0] and int [0]


Works if a is defined as "int a[0] = {};".
Comment 1 Daniel Krügler 2012-03-03 14:01:02 UTC
An array of length 0 is not valid. [dcl.array] p1:

"If the constant-expression (5.19) is present, it shall be an integral constant expression and its value shall be greater than zero."

Thus accepting

int a[0] = {};

or any such variant is a compiler defect.
Comment 2 Richard Biener 2012-03-05 10:39:44 UTC
Works for me on the 4.7 branch and on trunk.  Note that it requires -std=c++11
because of the constexpr use.

Can you clarify the target and command-line options you use?
Comment 3 Jonathan Wakely 2012-03-05 11:14:03 UTC
(In reply to comment #1)
> or any such variant is a compiler defect.

It's a GNU extension and is rejected with -pedantic-errors  (and compiles without ICE otherwise)

(In reply to comment #2)
> Can you clarify the target and command-line options you use?

And exact version, i.e. output of g++ -v

Basically all the info requested by http://gcc.gnu.org/bugs/ which should have been provided anyway
Comment 4 Martin Griffin 2012-03-05 14:14:45 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > Can you clarify the target and command-line options you use?
> 
> And exact version, i.e. output of g++ -v

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure : (reconfigured) ../gcc/configure : (reconfigured) ../gcc/configure
Thread model: posix
gcc version 4.7.0 20120214 (experimental) (GCC) 

 
> Basically all the info requested by http://gcc.gnu.org/bugs/ which should have
> been provided anyway

Sorry.
Comment 5 Paolo Carlini 2013-05-04 16:33:00 UTC
Closing.