This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/25152] -fstrict-aliasing generates wrong code, but no warning from -Wstrict-aliasing



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]