From: Ammar Faizi
Sent: 30 August 2023 15:41
On 8/28/23 4:51 AM, David Laight wrote:
I just found a(nother) clang bug: int f(void) { return "a"[2]; } compiles to just a 'return'.
I don't think that's a bug. It's undefined behavior due to an out-of-bound read. What do you expect it to return?
I was actually expecting a warning/error if it didn't just read the byte after the end of the string.
Just silently doing nothing didn't seem right for a modern compiler.
David
- Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)