Comment 6 for bug 1605158

Revision history for this message
Andre Vieira (andre-simoesdiasvieira) wrote :

Hi Konrad,

OK so in your example to get what you call the "non-inline constructor" to work, you need to define your own __cxa_pure_virtual () function to prevent it linking with the one in libstdc++. The implementation of __cxa_pure_virtual in libstdc++ uses writestr which is why you need --specs=nano.specs or --specs=rdimon.specs, pulling newlib's reentrant functions which use the embedded signal handling, which uses malloc...

So overriding __cxa_pure_virtual like:
extern "C" void __cxa_pure_virtual() { /* error or abort or hang? */ }

will get rid of your issue in the second compilation command.

What I am not understanding is why the first one optimizes away the constructor and the second one doesn't... I need to investigate further to figure this out.

Hope that helps.

Cheers,
Andre