Hi!
I have seen a msp430-gcc segfault today and cannot find a bug report for it,
yet. It has to do with two 32bit variables, which are part of the same struct.
The order of commands matters. Padding helps ;)
struct time {
long sec;
long usec;
};
// this function compiles ok
void time_add_ok( struct time *t1, struct time *t2 )
{
t1->usec += t2->usec; //micros first
t1->sec += t2->sec;
return;
}
// this function causes a compiler segfault
void time_add_segfault( struct time *t1, struct time *t2 )
{
t1->sec += t2->sec;
t1->usec += t2->usec; //micros second
return;
}
struct time {
int dummy; // padding with a dummy int here, fixes above segfault problem
long sec;
long usec;
};
I would appreciate if someone could give me a hint about it.
Albert
compiler details:
- gcc-3.3.6 sources patched with mspgcc patch gcc-3.4
- compiled with GCC 3.4