dereferencing type-punned pointer will break strict-aliasing rules
Marcel Behlau
marcel.behlau@elfin.de
Thu Jan 21 13:33:00 GMT 2016
Hi,
i wan't to create aliase (name and type) for the elements of an
char-array. Unfortunately my gcc produce the warning "dereferencing
type-punned pointer will break strict-aliasing rules", if i use -O2 or
bigger. Since i set -Werror, the warning will become an error.
I attached an example to this mail. To compile and generate the problem,
i use "gcc -O2 -Werror -Wall main.cpp".
I found an workaround (without using pragma, or somethink else), with
it's included in the code, too. To activate, pass an extra "-DWorking"
to the gcc-Command. The workaround is working, but using an pointer is
ugly.
Best regrads,
Marcel
--
Dipl. Ing (FH) Marcel Behlau
(Software Developer)
ELFIN GmbH
Siegburger StraÃe 215
50679 Köln
Germany
Tel: +49 (221) 6778932-0
Fax: +49 (221) 6778932-2
marcel.behlau@elfin.de
www.elfin.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cpp
Type: text/x-c++src
Size: 340 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20160121/4d26c47b/attachment.bin>
More information about the Gcc-bugs
mailing list