Re: [PATCH] A new version of the sys_swapon bugfix

Michael Riepe (michael@stud.uni-hannover.de)
Wed, 4 Nov 1998 02:10:51 +0100


On Tue, Nov 03, 1998 at 01:49:26PM -0800, Stephen Williams wrote:
> static int i = 0, *p;
> if (&p[i - 1] >= p) printf("C does not promote in pointer arithmetic\n");
[...]
> So I would say that any compiler that generates code that prints your
> message "C does not promote..." is broken, no matter how many bits in a
> pointer.

Your analysis is IMO correct, but there's one special case: In the
example above, p is static and not explicitly initialized, which usually
means that p equals 0x00000000. &p[i - 1] will then equal 0xfffffffc
(sizeof(int) == 4), which *is* greater than 0x00000000, if the C compiler
uses unsigned comparision for pointer values. If p is set to another
value, the message goes away (tested with gcc 2.7.2.x on i386).

-- 
 Michael "Tired" Riepe <Michael.Riepe@stud.uni-hannover.de>
 "All I wanna do is have a little fun before I die"

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/