This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/16197] CMSG_DATA results in (possibly correct) string aliasing warnings on gcc


https://sourceware.org/bugzilla/show_bug.cgi?id=16197

Rich Felker <bugdal at aerifal dot cx> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugdal at aerifal dot cx

--- Comment #1 from Rich Felker <bugdal at aerifal dot cx> ---
This is actually a complicated issue and unfortunately I think GCC is stuck in
the middle of an inconsistency in the standard. Per the standard, it's legal to
step around the representation of an object (an overlaid char-type array) using
offsets (e.g. obtained from offsetof()) and char pointers. For example, this
would *clearly* be valid:

*(T *)((char *)pmsg + offsetof(struct cmsghdr, __cmsg_data) + N)

(assuming there's an object of type T at offset N from the end of the message
header, which is plausible if pmsg points to storage obtained by malloc). But
(char *)pmsg + offsetof(struct cmsghdr, __cmsg_data) evaluates to the same
thing as pmsg->__cmsg_data (after array decay). So it's not clear how the
former can be valid and the latter an aliasing violation.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]