I know that the compiler may add some padding bytes in a struct. But is it possible, when the compiler sees that we never read from a variable inside a struct, that the struct will have a smaller size than the total size of the members?
struct Foo_T
{
int a;
intmax_t b;
};
void bar(void)
{
struct Foo_T foo;
foo.a=rand();
someFunction(foo.a);
//i never access foo.b, only foo.a
if(sizeof(foo)< sizeof(int)+sizeof(intmax_t))
{
//is it possible that we can end here?
}
}