Weird strict-aliasing break
Sebastian Huber
sebastian.huber@embedded-brains.de
Mon May 30 12:47:00 GMT 2011
Hi,
you may have a look at:
http://dbp-consulting.com/StrictAliasing.pdf
On 05/30/2011 10:34 AM, Thibault Castel wrote:
[...]
> int main (int ac, char** av)
> {
> TData data;
> char raw[10];
Character types can point to anything. I am not sure if this also includes
char []. Lets assume it does.
> TDummy* pFoo = NULL;
> char* pChar = NULL;
[...]
> // No warning - Why ???
> pFoo = (TDummy*) (raw);
Character types can point to anything.
[...]
> // Strict aliasing warning - Why ???
> pFoo = (TDummy*) (data.raw);
TDummy and TData are different types. You can modify now a TData through a
TDummy pointer and this violates the strict aliasing rules.
--
Sebastian Huber, embedded brains GmbH
Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone : +49 89 18 90 80 79-6
Fax : +49 89 18 90 80 79-9
E-Mail : sebastian.huber@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
More information about the Gcc-help
mailing list