Re: Weird strict-aliasing break

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx
PGP     : Public key available on request.

Diese Nachricht ist keine geschÃftliche Mitteilung im Sinne des EHUG.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux