https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107801

--- Comment #9 from Jan Dubiec <jdx at o2 dot pl> ---
I think I have found why the static assertion fails as mentioned in my previous
comment. Surprisingly, for H8/300H, H8/S and H8/SX in normal mode 32-bit
integers and floats are aligned on 4-byte boundaries.

Let's consider following structure:

struct foo
{
        uint32_t i;
        uint16_t j;
};

In advanced mode sizeof(struct foo) is 8. In normal mode, i.e. when the code is
compiled with -mn, the size is still 8 although one could expect it to be 6
(and that is why the assertion fails). In order to the size be 6 bytes,
-malign-300 must be used along with -mn.

So the natural solution seems to be adding -malign-300 to the compiler options
when libstdc++ is built in normal mode.

BTW. I do not even get why 4-byte boundaries are used at all. According to
H8/300H and H8/S software manuals (I didn't check H8/SX) "The CPU can access
word data and longword data in memory, but word or longword data must begin at
an even address." (longword is 32-bit word in Renesas' nomenclature). They do
not state that alignment must be 4 bytes for 32-bit integers and floats.

Reply via email to