internal compiler error: in output_constructor_regular_field, at varasm.c:4821

Asked by Freddie Chopin

I'm hitting an ICE in a rather complex C++ code using new features of C++11. I'm working on a simple test case, as I cannot publish what I have there now, but let me start with a description.

The problem occurs when I have derived classes, each with a constexpr constructor (the objects are created in read-only memory that way), which takes one parameter (pointer to const object). The problem I'm seeing is:
> internal compiler error: in output_constructor_regular_field, at varasm.c:4821
There are multiple levels of inheritance. The private field in base class is set with a constructor parameter, this parameter is passed verbatim from the most derived class to the base class with constructors. Derived classes have virtual functions.

Now some of my findings:
1. The strangest one - if the base class has an accessor for this field it fails, but if this accessor is virtual (it's not overridden anywhere) it works (probably related to vtable?)
2. If the constructors are not "constexpr" it works fine

Was there a similar bug for gcc? I see that there are some changes in this file and in this function in the trunk of GCC, but I don't know whether it changes anything...

I'll work on a testcase...

Thx for help!

Question information

Language:
English Edit question
Status:
Answered
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Freddie Chopin (freddie-chopin) said :
#1

OK, I've got the simpliest test case:

---

class Base
{
public:
 constexpr Base() : v(1) {};
 int v;
};

class Derived : public Base
{
public:
 constexpr Derived() : Base() {};
 virtual void function();
};

Derived d;

---

Compilation:
>arm-none-eabi-g++ -c -std=c++11 file.cpp -o file.o
file.cpp:15:10: internal compiler error: in output_constructor_regular_field, at varasm.c:4821
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Each of the listed things makes the problem go away:
- making function() non-virtual (or removing it)
- making both or at least Derived's constructor non-constexpr
- removing the member field "v" from base (along with the initializer in the constructor)

I'll check whether this ARM specific or not.

Any ideas?

Revision history for this message
Freddie Chopin (freddie-chopin) said :
#2

It's not ARM specific, I've filed a bug at gcc's bugzilla
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56291

Revision history for this message
Freddie Chopin (freddie-chopin) said :
#3

The bug was fixed - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56291#c13
Any chance of merging the fix with embedded 4.7 branch before the next relase? (;

Revision history for this message
Joey Ye (jinyun-ye) said :
#4

Should be fixed in next release
On Feb 13, 2013 2:15 AM, "Freddie Chopin" <
<email address hidden>> wrote:

> Question #221637 on GCC ARM Embedded changed:
> https://answers.launchpad.net/gcc-arm-embedded/+question/221637
>
> Freddie Chopin posted a new comment:
> The bug was fixed - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56291#c13
> Any chance of merging the fix with embedded 4.7 branch before the next
> relase? (;
>
> --
> You received this question notification because you are an answer
> contact for GCC ARM Embedded.
>

Can you help with this problem?

Provide an answer of your own, or ask Freddie Chopin for more information if necessary.

To post a message you must log in.