Robert C. Seacord wrote: > void f(char *buf) { > unsigned int len = len = 0xFFFFFF00; > > if (buf+len < buf) puts("true"); > > }
You need to be more precise. That is not the same example that you quoted for GCC. In fact, if you vary the criteria too much, you will find situations where GCC already behaved that way. The test in the following example is optimized out by old versions of GCC (certainly my version 3.4.5 compiler does it, with no warnings even when using -Wall): int f(char *buf, int i) { i = 1<<30; if ((int)buf + i < (int)buf) return 0; return 1; } That's quite a bit less changed than your example, which brings unsigned-ness into the picture. [This is exactly the problem--signed overflow and pointer overflow aren't defined, unlike unsigned overflow.] Given that current Microsoft compilers reportedly exhibit this behavior, it sounds like the advisory is going to at least need some significant rewriting. :-) -Jerry