Bug 47014 - [C++0x] ICE: tree check: expected tree that contains ‘decl minimal’ structure, have ‘nop_expr’ in decl_linkage, at cp/tree.c:2975
[C++0x] ICE: tree check: expected tree that contains ‘decl minimal’ structure...
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: c++
4.6.0
: P3 normal
: 4.6.1
Assigned To: Not yet assigned to anyone
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-12-19 14:40 UTC by 1zeeky
Modified: 2011-05-25 15:57 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
testcase (160 bytes, text/x-c++src)
2010-12-19 14:40 UTC, 1zeeky
Details

Note You need to log in before you can comment on or make changes to this bug.
Description 1zeeky 2010-12-19 14:40:26 UTC
Created attachment 22822 [details]
testcase

I (unsuccessfully) tried passing a lambda as a template-parameter and resorted to reinterpret_casting it to a normal function-pointer, which caused an internal compiler error and gcc telling me to report it.

$ gcc -v --save-temps -std=c++0x test.cpp
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --enable-gold --enable-ld --with-gold --enable-lto --disable-multilib --enable-languages=c,c++,lto --enable-threads
Thread model: posix
gcc version 4.6.0 20101212 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++0x' '-mtune=generic' '-march=x86-64'
 /usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/cc1plus -E -quiet -v -D_GNU_SOURCE test.cpp -mtune=generic -march=x86-64 -std=c++0x -fpch-preprocess -o test.ii
ignoring nonexistent directory "/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../include/c++/4.6.0
 /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../include/c++/4.6.0/x86_64-unknown-linux-gnu
 /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../include/c++/4.6.0/backward
 /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/include
 /usr/local/include
 /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++0x' '-mtune=generic' '-march=x86-64'
 /usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/cc1plus -fpreprocessed test.ii -quiet -dumpbase test.cpp -mtune=generic -march=x86-64 -auxbase test -std=c++0x -version -o test.s
GNU C++ (GCC) version 4.6.0 20101212 (experimental) (x86_64-unknown-linux-gnu)
	compiled by GNU C version 4.6.0 20101212 (experimental), GMP version 4.3.2, MPFR version 2.4.2-p1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C++ (GCC) version 4.6.0 20101212 (experimental) (x86_64-unknown-linux-gnu)
	compiled by GNU C version 4.6.0 20101212 (experimental), GMP version 4.3.2, MPFR version 2.4.2-p1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 1c7bc545debdfc2a0b314e4103e7e06d
test.cpp:8:18: internal compiler error: tree check: expected tree that contains ‘decl minimal’ structure, have ‘nop_expr’ in decl_linkage, at cp/tree.c:2975
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

I've attached test.cpp, which is very short and has almost the same contents as test.ii anyways.
Comment 1 1zeeky 2010-12-19 18:04:41 UTC
The problem arises (or at least seems to) whenever you 'force' (i.e. via reinterpret_cast) a non-function as template-parameter (e.g. an int fails to compile with almost the same ICE).
That would imply that a lambda is not regarded as a proper function, as the following fails as well with the same ICE as already posted:

template<void (fn)()>
class LambdaFunctor
{
};

LambdaFunctor<*[](){}> functor;
Comment 2 Jason Merrill 2011-05-25 15:57:26 UTC
In 4.6.1 gcc will give the error,

wa.C:6:21: error: ‘<lambda()>::operator void (*)()() const’ is not ‘constexpr’
wa.C:6:22: error: template argument 1 is invalid
wa.C:6:31: error: invalid type in declaration before ‘;’ token

This seems like an oversight in C++0x, I'll raise it with the committee.