Bug 50853 - [C++0x] Internal Compiler Error returning a template type using brace initialization
Summary: [C++0x] Internal Compiler Error returning a template type using brace initial...
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.1
: P3 normal
Target Milestone: 4.6.1
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2011-10-24 13:06 UTC by Alisdair Meredith
Modified: 2011-10-24 14:27 UTC (History)
0 users

See Also:
Known to work: 4.6.1, 4.7.0
Known to fail: 4.6.0
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Alisdair Meredith 2011-10-24 13:06:11 UTC
The following obscure code produces an ICE when the function template 'test' is called:

template<int> struct MyType{};

template<int VAL>
auto test(MyType<VAL>) -> MyType<int{VAL}> { return {}; }

int main() {
   test( MyType<256>{} );  // no error without this call

The ICE produced is:

internal compiler error: in tsubst_copy_and_build, at cp/pt.c:13389
Comment 1 Jonathan Wakely 2011-10-24 13:25:25 UTC
I get:  sorry, unimplemented: mangling constructor
Comment 2 Paolo Carlini 2011-10-24 13:46:42 UTC
Likewise here.
Comment 3 Alisdair Meredith 2011-10-24 14:02:22 UTC
The original report was compiled with gcc 4.6.1 supplied by MacPorts.  Could you confirm if the not-supported error message occurs in trunk, or a separately compiled gcc 4.6.1?
Comment 4 Jonathan Wakely 2011-10-24 14:06:26 UTC
The 4.6.1 release and trunk both give the error I quoted.

What does 'gcc -v' show for your compiler?
(that info should be in the report anyway! ;)
Comment 5 Alisdair Meredith 2011-10-24 14:10:38 UTC
Using built-in specs.
Target: x86_64-apple-darwin10
Configured with: ../gcc-4.6-20110325/configure --prefix=/opt/local --build=x86_64-apple-darwin10 --enable-languages=c,c++,objc,obj-c++ --libdir=/opt/local/lib/gcc46 --includedir=/opt/local/include/gcc46 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-4.6 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.6 --with-gxx-include-dir=/opt/local/include/gcc46/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --enable-stage1-checking --disable-multilib --enable-fully-dynamic-string
Thread model: posix
gcc version 4.6.1 20110325 (prerelease) (GCC) 

Hmm, that 'pre-rerelease' tag is annoying - the MacPorts port file updated to suggest this is the release version, rather than the release candidate.

Sounds like I have a bad version, anyway.  Sorry for the noise.
Comment 6 Jonathan Wakely 2011-10-24 14:20:55 UTC
ah yes, get the ICE with 4.6.0 so this appears to have been fixed for 4.6.1
Comment 7 Jonathan Wakely 2011-10-24 14:22:51 UTC
actually, I guess I was a bit hasty closing it ... there's no ICE but it still fails to compile - should we reopen?
Comment 8 Alisdair Meredith 2011-10-24 14:27:18 UTC
I am happy with closed - the ICE is resolved an PR50855 reports the unimplemented error message, with (hopefully) a simpler test case.

It might be worth re-testing once PR50855 is resolved, just to be sure though.