[Bug c++/64948] New: Lambda reference capture initialization in template function creates segmentation fault

my.pvt.emailaddress at googlemail dot com gcc-bugzilla@gcc.gnu.org
Thu Feb 5 15:15:00 GMT 2015


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

            Bug ID: 64948
           Summary: Lambda reference capture initialization in template
                    function creates segmentation fault
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: my.pvt.emailaddress at googlemail dot com

Compilation of the following code leads to the

Error Message
//<<<<<<<<<<<<<<<<<<<<<<<<<//
bug.cc: In function ‘void foo(T)’:
bug.cc:4:20: internal compiler error: Segmentation fault
     [&i = t.cbegin()]() {};
                    ^
//>>>>>>>>>>>>>>>>>>>>>>>>>//

The preprocessed file of a minimal testcase:

bug.ii
//<<<<<<<<<<<<<<<<<<<<<<<<<//
# 1 "bug.cc"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "bug.cc"
template <class T>
void
foo(T t) {
    [&i = t.cbegin()]() {};
}

int main() {
    return 0;
}
//>>>>>>>>>>>>>>>>>>>>>>>>>//

This happens with the

g++ version
//<<<<<<<<<<<<<<<<<<<<<<<<<//
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-linux-gnu/4.9.2/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: /build/gcc/src/gcc-4.9-20141224/configure --prefix=/usr
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch
--disable-libssp --enable-gnu-unique-object --enable-linker-build-id
--enable-cloog-backend=isl --enable-lto --enable-plugin
--enable-install-libiberty --with-linker-hash-style=gnu --disable-multilib
--disable-werror --enable-checking=release
Thread model: posix
gcc version 4.9.2 20141224 (prerelease) (GCC)
//>>>>>>>>>>>>>>>>>>>>>>>>>//

and the command
//<<<<<<<<<<<<<<<<<<<<<<<<<//
g++ --std=c++1y bug.cc
//>>>>>>>>>>>>>>>>>>>>>>>>>//

An equivalent(?) code which is perfektly compilable is

nobug.ii
//<<<<<<<<<<<<<<<<<<<<<<<<<//
# 1 "nobug.cc"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "nobug.cc"
template <class T>
void
foo(T t) {
    auto i = t.cbegin();
    [&i]() {};
}

int main() {
    return 0;
}
//>>>>>>>>>>>>>>>>>>>>>>>>>//


More information about the Gcc-bugs mailing list