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

            Bug ID: 57770
           Summary: non-static data member initializer in nested class and
                    default value in constructor cause compiler
                    segmentation fault
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: adam at mizerski dot pl

When compiling this:

struct A
{
    struct B
    {
        int i = 0;
    };

    B b;

    A(const B& _b = B())
        : b(_b)
    {}
};

with this command:
g++ -std=c++11 -c test.cpp

this happens:
test_cpp.cpp: In constructor 'constexpr A::B::B()':
test_cpp.cpp:36:12: internal compiler error: Segmentation fault


with this system:

gcc -v output:
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/4.7/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,java,ada
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.7
--enable-ssp --disable-libssp --disable-libitm --disable-plugin
--with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
--disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib
--enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch
--enable-version-specific-runtime-libs --enable-linker-build-id
--program-suffix=-4.7 --enable-linux-futex --without-system-libunwind
--with-arch-32=i586 --with-tune=generic --build=x86_64-suse-linux
Thread model: posix
gcc version 4.7.2 20130108 [gcc-4_7-branch revision 195012] (SUSE Linux)

uname -a output:
Linux etam-laptop.lan 3.7.10-1.16-desktop #1 SMP PREEMPT Fri May 31 20:21:23
UTC 2013 (97c14ba) x86_64 x86_64 x86_64 GNU/Linux

Above specification is default openSUSE 12.3. I could reproduce this bug also
on openSUSE 12.2 and Fedora 18.


Additional notes:
struct A
{
    struct B
    {
        int i;
        constexpr B() : i(0) {}
    };

    B b;

    A(const B& _b = B())
        : b(_b)
    {}
};

and

struct A
{
    struct B
    {
        int i = 0;
    };

    B b;

    A(const B& _b)
        : b(_b)
    {}
};

compiles fine.

Reply via email to