tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

re: NULL pointer arithmetic issues

> > Nonsense, I think it's fair to classify that as a bug.  That sort of
> > stuff is *not* supposed to happen if -ffreestanding is passed to the
> > compiler.
> If we use 0x0, it can be a valid pointer.
> If we use NULL, it's not expected to work and will eventually generate a
> syntax erro.

this is not true in GCC, since a while now -- 2 years ago i
had to write this code to stop GCC from emitting "trap" when
accessing the 0x0 pointer, from powerpc/oea/oea_machdep.c:

 * Load pointer with 0 behind GCC's back, otherwise it will
 * emit a "trap" instead.
static __inline__ uintptr_t
        uintptr_t dont_tell_gcc;

        __asm volatile ("li %0, 0" : "=r"(dont_tell_gcc) :);
        return dont_tell_gcc;


Home | Main Index | Thread Index | Old Index