GCC 4.7.3 internal compiler error when using std::make_shared

Bug #1165732 reported by Thomas Voß
44
This bug affects 9 people
Affects Status Importance Assigned to Milestone
gcc
Invalid
Medium
gcc-4.7 (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

GCC 4.7.3 crashes with an internal compiler error when trying to compile the following stripped-down test-case:

#include <memory>

namespace
{
struct Foo
{
    Foo(int) {}
};
}

int main(int, char**)
{
    auto foo = std::make_shared<Foo>();
    return 0;
}

Compiler command line is: g++ -std=c++11.

ProblemType: Crash
DistroRelease: Ubuntu 13.04
Package: g++-4.7 4.7.2-23ubuntu1
ProcVersionSignature: Ubuntu 3.8.0-7.15-generic 3.8.0
Uname: Linux 3.8.0-7-generic x86_64
ApportVersion: 2.9.2-0ubuntu5
Architecture: amd64
Date: Sat Apr 6 08:38:10 2013
ExecutablePath: /usr/lib/gcc/x86_64-linux-gnu/4.7/cc1plus
InstallationDate: Installed on 2013-02-23 (41 days ago)
InstallationMedia: Ubuntu 13.04 "Raring Ringtail" - Alpha amd64 (20130223.1)
MarkForUpload: True
SourcePackage: gcc-4.7
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Thomas Voß (thomas-voss) wrote :
Revision history for this message
Matthias Klose (doko) wrote :

both 4.6 and 4.8 give correct error messages

Changed in gcc-4.7 (Ubuntu):
status: New → Confirmed
Revision history for this message
In , Doko-v (doko-v) wrote :

works with 4.6 and 4.8, fails with the 4.7 branch

$ g++ -std=c++0x foo.cc
'
Internal compiler error: Error reporting routines re-entered.
Please submit a full bug report,
with preprocessed source if appropriate.

#include <memory>

namespace
{
struct Foo
{
    Foo(int) {}
};
}

int main(int, char**)
{
    auto foo = std::make_shared<Foo>();
    return 0;
}

Revision history for this message
In , Doko-v (doko-v) wrote :

works with 4.7.2, fails with 4.7.3

Changed in gcc:
importance: Unknown → Medium
status: Unknown → New
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

The error is actually more to do with trying to call a class constructor inside of make_shared that results in an error. For example, the following will also raise an internal compiler error:

#include <memory>

class Foo
{
    public:
        virtual ~Foo () = default;
        virtual void bar () = 0;
};

int main ()
{
    auto foo = std::make_shared <Foo> ();
    return 0;
}

Revision history for this message
In , Rguenth (rguenth) wrote :

works for me on the 4.7 branch (x86_64-linux) with preprocessed source from
using 4.7.2.

So it might be triggered by a libstdc++ change?

Can you attach preprocessed source?

Revision history for this message
In , Doko-v (doko-v) wrote :

Created attachment 29822
preprocessed source

Revision history for this message
In , Rguenth (rguenth) wrote :

Also fails with GCC 4.7.0 GCC 4.6 ICEs for me with

in dependent_type_p, at cp/pt.c:18136
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

(confused by earlier errors)

4.5 seems to "work".

Factoring in libstdc++ changes the point of the regression.

Changed in gcc:
status: New → Confirmed
Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

GCC 4.6.4 has been released and the branch has been closed.

Revision history for this message
Jitendra Kulkarni (kulkarnij) wrote :

I also encountered similar situation where make_shared<> crashes but casting through new works.
Note that make_shared<> worked for object of another class. Attached file.

g++ (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3

Linux jeeves 3.8.0-25-generic #37-Ubuntu SMP Thu Jun 6 20:47:07 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

g++ -c -I/usr/local/include -I ../include -std=c++11 EventWheel.cpp

Revision history for this message
Jitendra Kulkarni (kulkarnij) wrote :

I am on Ubunto 13.04.
The previous file (ccDenxuK.out) was with the statement:Event reset= *(Event::EventPointer(new Event()));
The current one is with the statement: Event reset= *(Event::EventPointer(make_shared<Event>()));

The following statement works:Event reset= *(Event::EventPointer(new Event()));

Revision history for this message
Jitendra Kulkarni (kulkarnij) wrote :

Correction: ccDenxuK.out was with: Event reset= *(make_shared<Event>();

Revision history for this message
John-Paul Gignac (jp-gignac) wrote :

This non-program causes the same internal error in gcc 4.7.3 (with -std=c++0x and -std=c++11). In general, it seems to happen any time I push_back an object with an inaccessible copy constructor.

#include <vector>

class A {
    A(const A&)=delete;
};

int main()
{
    std::vector<A>().push_back(*(A*)0);
    return 0;
}

Revision history for this message
In , Paolo-carlini (paolo-carlini) wrote :

Let's close this.

Changed in gcc:
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.