https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71498
Martin Liška <marxin at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2016-06-13 CC| |marxin at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> --- Problem is in function ubsan_walk_array_refs_r, where we skip all static variables: /* Since walk_tree doesn't call the callback function on the decls in BIND_EXPR_VARS, we have to walk them manually. */ if (TREE_CODE (*tp) == BIND_EXPR) { for (tree decl = BIND_EXPR_VARS (*tp); decl; decl = DECL_CHAIN (decl)) { if (TREE_STATIC (decl)) { *walk_subtrees = 0; continue; } where FUNCTION is a static var_decl: (gdb) p debug_tree(decl) <var_decl 0x7ffff7fedd80 FUNCTION type <array_type 0x7ffff69e12a0 type <integer_type 0x7ffff68a6000 char readonly string-flag QI size <integer_cst 0x7ffff6881d98 constant 8> unit size <integer_cst 0x7ffff6881db0 constant 1> align 8 symtab 0 alias set -1 canonical type 0x7ffff68a6000 precision 8 min <integer_cst 0x7ffff6881de0 -128> max <integer_cst 0x7ffff6881e10 127> pointer_to_this <pointer_type 0x7ffff68a60a8>> BLK size <integer_cst 0x7ffff69c9798 constant 56> unit size <integer_cst 0x7ffff69c9768 constant 7> align 8 symtab 0 alias set -1 canonical type 0x7ffff69e12a0 domain <integer_type 0x7ffff69e1000 type <integer_type 0x7ffff68851f8 sizetype> DI size <integer_cst 0x7ffff6881ca8 constant 64> unit size <integer_cst 0x7ffff6881cc0 constant 8> align 64 symtab 0 alias set -1 canonical type 0x7ffff69e1000 precision 64 min <integer_cst 0x7ffff6881cd8 0> max <integer_cst 0x7ffff69c9750 6>> pointer_to_this <pointer_type 0x7ffff69e1348>> readonly addressable used static BLK file pr71498.c line 5 col 22 size <integer_cst 0x7ffff69c9798 56> unit size <integer_cst 0x7ffff69c9768 7> align 8 context <function_decl 0x7ffff69bea00 testje> initial <string_cst 0x7ffff69c8ca0>> I'm wondering why are static vars skipped?