array subscript is below array bounds : false positive?

Richard Henderson rth@redhat.com
Tue Sep 15 16:19:00 GMT 2009


On 09/15/2009 09:56 AM, Ian Lance Taylor wrote:
> void assert_failure () __attribute__ ((noreturn, always_inline));
> void assert_failure() { __asm__ ("int $0x03"); }
> #define ASSERT(x) if (x) { } else { assert_failure(); }

Incidentally, there's a __builtin_trap() that you may wish to use.  It 
won't invoke interrupt 3 like you currently do, but it will abort the 
program, and you'll be able to see from whence in the debugger.

Additionally, there are targets for which there exists a conditional 
trap instruction, e.g. sparc:

    cmp 0, %i0	// x in register %i0
    tne 0	// invoke trap vector 0 if compare is "not-equal"


r~



More information about the Gcc mailing list