Taking the address of a bitfield

c

Solution

The foo field is a 4-bit wide bit-field – smaller than a single byte. Pointers can only address whole bytes, so this is invalid. Even if foo was 8 or 32 bits wide (full/aligned bytes on modern architectures) this would still be invalid.

Problem

I'm going through few C aptitude questions. This one seemed tricky, can any one explain? ``` struct { int foo : 4; } baz; int *example() { return &baz.foo; } ``` This is invalid code, but i couldn't figure out the reason.

Original source