[LLVMdev] should asan catch tihs?

Rafael EspĂ­ndola rafael.espindola at gmail.com
Fri Nov 2 18:27:35 PDT 2012


I just tried asan on an optimized  32 bit build of
-------------------------------------
#include <stdint.h>
__attribute__((noinline))
 void f(uint64_t *p) {
  *p = 42;
}
int main() {
  void *p;
  f((uint64_t*)&p);
}
------------------------------------

and it correctly catches the invalid access. If I comment the
attribute, the optimizers find and exploit the undefined behavior and
asan fails to report it. Is this the expected behavior? Is this
something that needs -fcatch-undefined-behavior instead?

Cheers,
Rafael



More information about the llvm-dev mailing list