Michael Haubenwallner writes: > On Mon, 2007-01-08 at 15:39 +0000, Andrew Haley wrote: > > Michael Haubenwallner writes: > > > Hi, > > > > > > after switching to gcc-4.1.1 from gcc-3.4.5, I'm facing a problem with > > > this code searching for non-blank in a string (extracted test-case): > > > > > > #include <stdio.h> > > > int check(const void *pvBuf) > > > { > > > for(; *((char*)pvBuf) == ' '; ++ *((char**)&pvBuf)); > > > > This is wrong. Try this: > > > > for(; *((char*)pvBuf) == ' '; pvBuf = (char*)pvbuf + 1); > > Yep, have my code changed like this, thanks. > > > This is an aliasing bug. Please see The C standard, Section 6.3.2.3, > > Pointers. > > Hmm, a bug in what product - the standard, gcc, or my application ? The standard is generally assumed not to have bugs. :-) > And - sorry for that question - where do one read the standard from > ? I've found C89, this seems to have only 5 sections... And in > the C99 draft, Section 6.3.2.3 has to do with aliasing, but I'm > completely lost here - I'll better let interpreting the standard up > to you :) In C99, 6.3.2.3 tells you which pointer conversions you're allowed to do, and what you're alowed to do with the converted pointers. Any pointer conversions that are not described in that section have undefined effect. The pointer conversion you use above is not not defined there, so ... Andrew.