Bug 55564 - [4.8 Regression] internal error using decltype of a template type parameter for late-specified function result type
Summary: [4.8 Regression] internal error using decltype of a template type parameter f...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: 4.8.0
Assignee: Jason Merrill
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-02 19:30 UTC by Alisdair Meredith
Modified: 2012-12-06 14:42 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-12-02 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alisdair Meredith 2012-12-02 19:30:27 UTC
The following program gives an internal compiler error, when built with the command line:  g++ -std=c++11 main.cpp

//---------------------------------------------------

template <typename T, decltype(sizeof(T)) N>
auto array_size(T(&)[N]) -> decltype(N) { return N; }

int main() {
   int simple[4] = {};
   int result =  array_size(simple);

   return result;
}

//---------------------------------------------------


The error I get from my build of gcc is:

main.cpp: In function 'int main()':
main.cpp:1:38: internal compiler error: in dependent_type_p, at cp/pt.c:19249
 template <typename T, decltype(sizeof(T)) N>
                                      ^

main.cpp:1:38: internal compiler error: Abort trap: 6
g++-mp-4.8: internal compiler error: Abort trap: 6 (program cc1plus)
Abort trap: 6


Build is a recent version obtained from MacPorts, running on the latest Apple Mountain Lion OS with up to date patches.

g++ -v:

Using built-in specs.
COLLECT_GCC=g++-mp-4.8
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin12/4.8.0/lto-wrapper
Target: x86_64-apple-darwin12
Configured with: ../gcc-4.8-20121125/configure --prefix=/opt/local --build=x86_64-apple-darwin12 --enable-languages=c,c++,objc,obj-c++,fortran,java --libdir=/opt/local/lib/gcc48 --includedir=/opt/local/include/gcc48 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-4.8 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.8 --with-gxx-include-dir=/opt/local/include/gcc48/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-ppl=/opt/local --with-cloog=/opt/local --enable-cloog-backend=isl --disable-cloog-version-check --enable-stage1-checking --disable-multilib --enable-lto --enable-libstdcxx-time --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --with-pkgversion='MacPorts gcc48 4.8-20121125_0'
Thread model: posix
gcc version 4.8.0 20121125 (experimental) (MacPorts gcc48 4.8-20121125_0)
Comment 1 Paolo Carlini 2012-12-02 23:52:30 UTC
Seems a regression.
Comment 2 Paolo Carlini 2012-12-03 17:44:37 UTC
HJ, can you find when we regressed on this?
Comment 3 H.J. Lu 2012-12-03 17:49:32 UTC
It is caused by revision 190830:

http://gcc.gnu.org/ml/gcc-cvs/2012-08/msg00809.html
Comment 4 Paolo Carlini 2012-12-03 17:58:13 UTC
Are you kidding? This is a front-end issue and happens also at -O0.
Comment 5 H.J. Lu 2012-12-03 18:07:06 UTC
(In reply to comment #3)
> It is caused by revision 190830:
> 
> http://gcc.gnu.org/ml/gcc-cvs/2012-08/msg00809.html

Oops. Right revision, wrong link:

http://gcc.gnu.org/ml/gcc-cvs/2012-08/msg00808.html
Comment 6 Paolo Carlini 2012-12-03 18:21:56 UTC
Thanks.
Comment 7 Jason Merrill 2012-12-06 14:36:59 UTC
Author: jason
Date: Thu Dec  6 14:36:55 2012
New Revision: 194248

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194248
Log:
	PR c++/55564
	* pt.c (unify) [ARRAY_TYPE]: Unify the element type before the bounds.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/decltype47.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
Comment 8 Jason Merrill 2012-12-06 14:42:08 UTC
Fixed.