I have been experimenting with the binaries generated with the ARM GCC compiler (Version 9.2.1). I noticed that even if I compiled the program with C++14 support, the lenient rules for POD types in are not used to put the struct definition in the rodata section.
For example:
struct DigitalOut
{
uint32_t port;
uint32_t pin;
uin32_t output_type;
uint32_t output_speed;
}
This version is put in the rodata section if instantiated using brace initializers.
However if I introduce the specific constructor for the struct as show below, then its not put in the rodata section
struct DigitalOut
{
DigitalOut() = default;
DigitalOut(uint32_t port, uint32_t pin) :
port{port},
pin{pin},
output_type{500} //just an example
output_speed{400} {}
uint32_t port;
uint32_t pin;
uin32_t output_type;
uint32_t output_speed;
}
What am I missing here? I am pretty sure I understand the C++'s updated definition for POD types, Trivially constructible and copyable classes and Standard layouts.
Link to the answer related to updated definiton POD types
Edit:
My question is regarding why would the compiler not able to do this? Could this be a missing feature in the compiler or am I doing something wrong?