Aligned access to packed struct
Hi,
I observe a problem with aligned access on M0. I try both gcc version with the same problem. (4.6q4 and 4.7u1).
I get an Hardfault with this code.
-------
typedef struct Struct_HdrPrefix{
uint8_t Prefix;
uint16_t Type;
uint16_t Size;
}__attribute(
volatile Struct_HdrPrefix test;
volatile Struct_HdrPrefix test1;
int main(void)
{
test.Type = 0;
while(1)
__asm("nop");
}
-------
Compile line
arm-none-eabi-gcc -DPRELOADER -DSTM32F0X_MD -DSTM32F0XX -I"C:\projects\
If I don't optimise the code, everythig works well.
IF I use Os, I got the hardfault.
Should I add something in the compiling line or linking to not having the Hardfault. This look like an alignement problem.
regards
Jonathan
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Joey Ye
- Solved:
- Last query:
- Last reply: