This is the mail archive of the
mailing list for the GCC project.
GCC aliasing extension for C
- From: Florian Weimer <fweimer at redhat dot com>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 18 Sep 2017 11:48:07 +0200
- Subject: GCC aliasing extension for C
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=fweimer at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D357AC04B938
I know that GCC implements a C extension (which is more or less required
by POSIX) which allows you to define a buffer
and then allocate objects from that (assuming that the buffer is
sufficiently large and the pointers to subobjects are suitably aligned).
In short, it is possible to change the dynamic type of an object even
if it was defined with a type.
The object is first written under the new type, and only accessed under
the new type. It is also possible that the buffer is reused and
different objects with different types at the same offsets are carved
out from it.
Is this a property of the char type, or would other types work as well,
for example, double or long double?