3 ms·
> my suspicion is that if one is undefined behavior the other probably is too I would suspect otherwise. I have no particularly good reason for that, but the c
by slavik81 11y ago
> my suspicion is that if one is undefined behavior the other probably is too
I would suspect otherwise. I have no particularly good reason for that, but the cases with and without warnings match to my expectations of what's valid and what's not. Intuitively, I'd expect pointers can point to any valid memory, while array accesses can only be done within the dimensions of the array.
- jepler 11y agoYou may be right. I haven't gone and read the standard yet, but I also fed related programs to cbmc 4.9, a C-program verifier, using the -bounds-check flag. It tags x[0][3] as an out-of-bounds access, but not f = &x[0][0]; f[3]; (also (x[0]+i) is OK according to cbmc, despite what we all learned about (a+b) and a[b] being the same!) Neither variant is picked up as illegal at runtime by -fsanitize=address and gcc-4.9 or clang-3.5.