This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/40698] Incorrect code generation when compiling c++ source
- From: "manu at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Jul 2009 15:35:28 -0000
- Subject: [Bug c++/40698] Incorrect code generation when compiling c++ source
- References: <bug-40698-17931@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #7 from manu at gcc dot gnu dot org 2009-07-09 15:35 -------
@Jacob,
The C/C++ standards have some precise rules of what can and cannot be done
about pointer casts.
See
http://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Optimize-Options.html#index-fstrict_002daliasing-749
See also the documentation of -Wstrict-aliasing.
This is warned by GCC by using -Wall.
manu@localhost:~$ gcc --version
gcc (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu4)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
manu@localhost:~$ g++ -Wall -O2 pr40698.c -c
pr40698.c: In function ?TwoPointers InterlockedExchange(TwoPointers*,
TwoPointers)?:
pr40698.c:55: warning: dereferencing type-punned pointer will break
strict-aliasing rules
pr40698.c:55: warning: dereferencing type-punned pointer will break
strict-aliasing rules
pr40698.c:56: warning: dereferencing type-punned pointer will break
strict-aliasing rules
pr40698.c: In function ?int main()?:
pr40698.c:80: warning: dereferencing type-punned pointer will break
strict-aliasing rules
pr40698.c:81: warning: dereferencing type-punned pointer will break
strict-aliasing rules
pr40698.c:63: warning: unused variable ?i?
pr40698.c:64: warning: unused variable ?j?
If you have more questions, please do ask.
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40698