Wrong handling of big struct size, possible compiler bug?

Look at this code sample:

[i]#define MAX_QSIZE 258

typedef struct {
byte data[255];
} a_type;

typedef struct {
a_type data[MAX_QSIZE];
} b_type;

far b_type b;
main () {
", sizeof(b));

It compiles and runs, but something strange (and possibly dangerous) is obviously happening here: “b_type” should be too big to handle (258x255=65790) but the compiler is not complaining about it, and allocates 254 bytes for “b”

By the way: 254 = 65790 & 0xffff …

Yes, it is a bug .

1 Like