Hi! Apparently fold_build_addr_expr doesn't make the argument addressable, it is only made addressable during following gimplification and that is too late here.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2017-03-06 Jakub Jelinek <ja...@redhat.com> PR sanitizer/79897 * ubsan.c (ubsan_encode_value): Call mark_addressable on the temporary. --- gcc/ubsan.c.jj 2017-02-21 09:03:57.000000000 +0100 +++ gcc/ubsan.c 2017-03-06 21:37:32.013422810 +0100 @@ -145,6 +145,7 @@ ubsan_encode_value (tree t, bool in_expa code by making vars unnecessarily addressable. */ tree var = create_tmp_var (type); tree tem = build2 (MODIFY_EXPR, void_type_node, var, t); + mark_addressable (var); if (in_expand_p) { rtx mem --- gcc/testsuite/c-c++-common/ubsan/pr79897.c.jj 2017-03-06 21:48:01.007297214 +0100 +++ gcc/testsuite/c-c++-common/ubsan/pr79897.c 2017-03-06 21:42:56.505230894 +0100 @@ -0,0 +1,15 @@ +/* PR sanitizer/79897 */ +/* { dg-do compile } */ +/* { dg-options "-fsanitize=enum -O2" } */ + +enum E +{ + A = 0, + B = ~0U + 1LL +} x = A; + +int +main () +{ + return x != A; +} Jakub