http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56013



             Bug #: 56013

           Summary: ICE in lambda in a for-each in templated class

    Classification: Unclassified

           Product: gcc

           Version: 4.7.2

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: cool.pepy...@yandex.ru





Created attachment 29186

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29186

Preprocessed source



gcc ICEs with segfault on the following code:



#include <string>



typedef std::string Container;



template <typename T>

class Base {

    public:

        Container container;



        char Sum() const {

            auto Summarizer = [this] () -> char {

                for (auto& c : container) { // segfaults here

                    return c;

                }

            };



            return Summarizer();

        }

};



int main() {

    return 0;

}



I've tested it on Ubuntu Linux (12.10), on g++ 4.7.2 and g++ 4.7.3 with the

same result. The type of the `Container' doesn't really matter, it works on

`std::vector' or on a user-defined class with `begin()' and `end()' methods.



  Compilation (g++ try.cpp -o try -std=c++11 -v -save-temps) outputs:

Using built-in specs.

COLLECT_GCC=g++

COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper

Target: x86_64-linux-gnu

Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro

4.7.2-2ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs

--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr

--program-suffix=-4.7 --enable-shared --enable-linker-build-id

--with-system-zlib --libexecdir=/usr/lib --without-included-gettext

--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7

--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu

--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object

--enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686

--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu

--host=x86_64-linux-gnu --target=x86_64-linux-gnu

Thread model: posix

gcc version 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1) 

COLLECT_GCC_OPTIONS='-o' 'try' '-std=c++11' '-v' '-save-temps' '-shared-libgcc'

'-mtune=generic' '-march=x86-64'

 /usr/lib/gcc/x86_64-linux-gnu/4.7/cc1plus -E -quiet -v -imultiarch

x86_64-linux-gnu -D_GNU_SOURCE try.cpp -mtune=generic -march=x86-64 -std=c++11

-fpch-preprocess -fstack-protector -o try.ii

ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"

ignoring nonexistent directory

"/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/include"

#include "..." search starts here:

#include <...> search starts here:

 /usr/include/c++/4.7

 /usr/include/c++/4.7/x86_64-linux-gnu

 /usr/include/c++/4.7/backward

 /usr/lib/gcc/x86_64-linux-gnu/4.7/include

 /usr/local/include

 /usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed

 /usr/include/x86_64-linux-gnu

 /usr/include

End of search list.

COLLECT_GCC_OPTIONS='-o' 'try' '-std=c++11' '-v' '-save-temps' '-shared-libgcc'

'-mtune=generic' '-march=x86-64'

 /usr/lib/gcc/x86_64-linux-gnu/4.7/cc1plus -fpreprocessed try.ii -quiet

-dumpbase try.cpp -mtune=generic -march=x86-64 -auxbase try -std=c++11 -version

-fstack-protector -o try.s

GNU C++ (Ubuntu/Linaro 4.7.2-2ubuntu1) version 4.7.2 (x86_64-linux-gnu)

    compiled by GNU C version 4.7.2, GMP version 5.0.2, MPFR version 3.1.0-p3,

MPC version 0.9

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072

GNU C++ (Ubuntu/Linaro 4.7.2-2ubuntu1) version 4.7.2 (x86_64-linux-gnu)

    compiled by GNU C version 4.7.2, GMP version 5.0.2, MPFR version 3.1.0-p3,

MPC version 0.9

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072

Compiler executable checksum: 521527ea42f0901bf839bcaad0cb13e6

try.cpp: In lambda function:

try.cpp:12:32: internal compiler error: Segmentation fault

Please submit a full bug report,

with preprocessed source if appropriate.

See <file:///usr/share/doc/gcc-4.7/README.Bugs> for instructions.

Preprocessed source stored into /tmp/ccTNb1rl.out file, please attach this to

your bugreport.

Reply via email to