Open
Description
If building the following with -fsanitize=object-size
, the sanitizer correctly flags the code as UB...
#include <stddef.h>
void ReadValueOutOfArrayBoundsRight(char *ptr, size_t size) {
char c = ptr[size + 1];
}
int main() {
char foo[16];
ReadValueOutOfArrayBoundsRight(foo, 16);
}
https://godbolt.org/z/e4oWfYdPG
However, the error it outputs is:
/app/example.cpp:4:12: runtime error: load of misaligned address 0x7ffcd4609ba1 for type 'char', which requires 2 byte alignment
This does not make sense because char
does not require 2 byte alignment, and indeed the alignment is just fine. It's just out of bounds.