On Fri, 19 Mar 2021, Dmitry Selyutin wrote:

Some complex types can still be small and simple enough to fit into register. Other compilers allow some operations on these types, and it seems to be quite a reasonable choice.

How should padding be handled?  For example:

struct foo {
        uint8_t a;
        uint16_t b;
};
struct foo x, y;
memset(&x, 1, sizeof(x));
memset(&y, 2, sizeof(y));
x.a = y.a = x.b = y.b = 0;
atomic_compare_exchange(&x, &y, y);

All of the members of x and y are the same, so it seems like it makes sense for the comparison to succeed. But there is (might be) a padding byte which is 1 for x and 2 for y, causing the comparison to fail.

 -E

_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to