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.
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: virtual( ) { /* error or abort or hang? */ }
extern "C" void __cxa_pure_
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