This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/16197] CMSG_DATA results in (possibly correct) string aliasing warnings on gcc
- From: "bugdal at aerifal dot cx" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Thu, 21 Nov 2013 00:26:12 +0000
- Subject: [Bug libc/16197] CMSG_DATA results in (possibly correct) string aliasing warnings on gcc
- Auto-submitted: auto-generated
- References: <bug-16197-131 at http dot sourceware dot org/bugzilla/>
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.