"xrun: Program received signal ET_LOAD_STORE, Memory access exception."
As I understand it is convention on 32bit platforms that int members and struct sizes should be aligned to 4 bytes boundaries. This mostly seems to be the case with xc, However consider this code:
Code: Select all
#include <stdint.h>
#include <stdio.h>
#include <xassert.h>
typedef struct {
int8_t a;
uint32_t b;
int8_t c;
} test1_t;
typedef struct {
uint8_t a;
uint16_t b;
uint8_t c[1536];
uint16_t d;
// uint8_t padding[2]; // fixes issue but should be inserted by compiler
} test2_t;
void testAligment(void) {
test1_t t1;
test2_t t2;
xassert(&t1.a + 4 == &t1.b); // test padding of int b to 4 byte alignment: OK
xassert(sizeof(t1) % 4 == 0); // test padding of struct size t1 to 4 byte alignment: OK
xassert(sizeof(t2) % 4 == 0); // test the same for t2: FAILS!
}