[Bug c++/88324] New: segfault with constexpr lambda in template arguments

amonakov at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Dec 3 17:54:00 GMT 2018


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

            Bug ID: 88324
           Summary: segfault with constexpr lambda in template arguments
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amonakov at gcc dot gnu.org
  Target Milestone: ---

With -std=c++17 GCC segfaults on

template<int=[]()constexpr{return 42;}()>
int f()
{
    return 0;
}
template int f();

Clang accepts with -fsyntax-only, segfaults trying to mangle. MSVC accepts. GCC
produces


<source>: In lambda function:
<source>:1:35: error: invalid use of 'auto'
    1 | template<int=[]()constexpr{return 42;}()>
      |                                   ^~
<source>:1:35: error: could not convert '42' from 'int' to 'auto'
<source>: At global scope:
<source>:1:14: error: use of '<lambda()>' before deduction of 'auto'
    1 | template<int=[]()constexpr{return 42;}()>
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~
<source>: In static member function 'static auto<lambda()>::_FUN()':
<source>:1:14: error: invalid use of 'auto'
<source>: At global scope:
<source>:1:40: internal compiler error: Segmentation fault


More information about the Gcc-bugs mailing list