Bug 57770 - non-static data member initializer in nested class and default value in constructor cause compiler segmentation fault
Summary: non-static data member initializer in nested class and default value in const...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 57781 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-07-01 19:17 UTC by Adam Mizerski
Modified: 2013-07-02 16:37 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work: 4.8.0, 4.9.0
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Mizerski 2013-07-01 19:17:39 UTC
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.
Comment 1 Paolo Carlini 2013-07-01 19:28:14 UTC
Mainline and 4_8-branch are fine.
Comment 2 Paolo Carlini 2013-07-02 16:37:29 UTC
*** Bug 57781 has been marked as a duplicate of this bug. ***