http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51628



--- Comment #17 from Richard Biener <rguenth at gcc dot gnu.org> 2013-04-02 
08:30:54 UTC ---

(In reply to comment #15)

> I believe the discussion here is missing the point. Currently (at least with

> version 4.5 and ARM, which I am currently using) the situation is that the

> compiler generates broken code WITHOUT COMMENT when the address of something

> like an integer in a packed structure is assigned to a int* . Since the 
> pointer

> type does not provide any information about the actual alignment of the

> integer, it is obviously impractical to fix when accessing the integer and we

> certainly do not want to have extra code inserted for handling the possibility

> that the int may not be aligned correctly. Therefore the compiler MUST see 
> this

> as a type conflict and at least warn that the address of the member in a 
> packed

> struct is incompatible with the pointer type.

> 

> I have several projects which require the use of packed structures and I 
> simply

> cannot rule out that that I have not at some point accidentally assigned the

> address of a member variable to a pointer. It would therefore be very handy if

> the compiler could point this out. -Wcast-align certainly doesn't do this.



Because there is no cast involved.  And that's because the types of the fields

are "wrong" as well.

Reply via email to