Re: array subscript is below array bounds : false positive?

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

 



Peter A. Felvegi wrote:
> Andrew Haley wrote:
>> Peter A. Felvegi wrote:
>>> Ian Lance Taylor wrote:
>>
>>>> You can avoid this kind of thing by telling gcc that your assert
>>>> condition does not return.
>>>>
>>>> void assert_failure () __attribute__ ((noreturn, always_inline));
>>>> void assert_failure() { __asm__ ("int $0x03"); }
>>>> #define ASSERT(x) if (x) { } else { assert_failure(); }
>>> Now I got 'noreturn function does return' warning/error in
>>> assert_failure().
>>
>> void assert_failure() {
>>   for (;;)
>>     __asm__ ("int $0x03");
>> }
> 
> Remarks:

> 3) the for(;;) loop solves the above 'noreturn function does return'
> error, but it also prohibits continuing the prg from the debugger.

Correct, since this would result in undefined behaviour.  That's the idea.

Andrew.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux