This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/25152] -fstrict-aliasing generates wrong code, but no warning from -Wstrict-aliasing
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Nov 2005 15:12:51 -0000
- Subject: [Bug c++/25152] -fstrict-aliasing generates wrong code, but no warning from -Wstrict-aliasing
- References: <bug-25152-11785@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from pinskia at gcc dot gnu dot org 2005-11-29 15:12 -------
4.2 warns:
t.cc: In function 'CvStatus icvSet_8u_C4MR(int*, int, const uchar*, int,
CvSize, const int*)':
t.cc:21: warning: dereferencing type-punned pointer will break strict-aliasing
rules
Because the warning was not in 4.1.0 at all for C++.
This is invalid as:
CvStatus
icvSet_8u_C4MR (int *dst, int step, const uchar * mask, int step2,
CvSize size, const int *scalar)
{
int s0 = scalar[0];
for (; size.height--; mask += step2, (char *&) dst += step)
{
"(char *&) dst += step" is equaliant to *((char**)&dst) += step
so we are accessing dst as a "char*" which violates alaiasing rules.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25152