[Bug c++/79331] ICE on valid C++14 code (with initialized lambda capture) on x86_64-linux-gnu: in canonicalize_component_ref, at gimplify.c:2451

su at cs dot ucdavis.edu gcc-bugzilla@gcc.gnu.org
Fri Feb 3 19:27:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79331

--- Comment #3 from Zhendong Su <su at cs dot ucdavis.edu> ---
(In reply to Richard Biener from comment #2)
> rejected with GCC 6:
> 
> t.C: In function ‘int bar()’:
> t.C:5:12: error: invalid initialization of non-const reference of type ‘int
> (*&)()’ from an rvalue of type ‘int (*)()’
>      return [&f (foo)]
>             ^
> 
> and clang:
> 
> t.C:5:12: error: expected expression
>     return [&f (foo)] 
>            ^

This is valid C++14 code, and correctly accepted by both Clang and ICC: 

$ icc -c -std=c++14 small.cpp
$ clang++ -c -std=c++14 small.cpp
$ 
$ g++-6.2 -c -std=c++14 small.cpp
small.cpp: In function ‘int bar()’:
small.cpp:5:10: error: invalid initialization of non-const reference of type
‘int (*&)()’ from an rvalue of type ‘int (*)()’
   return [&f (foo)]
          ^
$


More information about the Gcc-bugs mailing list