PR c++/101331
gcc/ChangeLog:
* asan.h (sanitize_coverage_p): Handle when fn == NULL.
gcc/testsuite/ChangeLog:
* g++.dg/pr101331.C: New test.
sanitize_coverage_p (const_tree fn = current_function_decl)
{
return (flag_sanitize_coverage
- && lookup_attribute ("no_sanitize_coverage",
- DECL_ATTRIBUTES (fn)) == NULL_TREE);
+ && (fn == NULL_TREE
+ || lookup_attribute ("no_sanitize_coverage",
+ DECL_ATTRIBUTES (fn)) == NULL_TREE));
}
#endif /* TREE_ASAN */
--- /dev/null
+// PR c++/101331
+// { dg-do compile }
+// { dg-options "-fsanitize-coverage=trace-pc -O2 -std=c++11" }
+
+int a[2];
+int b = 1;
+int c { b && (a[b] = 0) };