For the following program, compilation with -O1 works, but compilation with -O1 -fsanitize=address fails. clang works. ---- struct f { void (*func)(void); }; extern void link_error(void); extern int printf(const char *f, ...); static inline struct f *gimme_null(struct f *result) { return 0; } int main(int argc, char **argv) { struct f *x = gimme_null(&(struct f) { .func = link_error }); printf("%p", x); } ---- Without -fsanitize=address, dse1 removes the dead store to the compound literal. With -fsanitize=address, however, ASAN_MARK causes the compound literal to escape: main (int argc, char * * argv) { struct f * D.2139; struct f * x; struct f D.2129; <bb 2> [100.00%]: ASAN_MARK (UNPOISON, &D.2129, 8); D.2129.func = link_error; printf ("%p", 0B); return 0; }
Author: bonzini Date: Mon Feb 12 12:47:56 2018 New Revision: 257585 URL: https://gcc.gnu.org/viewcvs?rev=257585&root=gcc&view=rev Log: gcc: 2018-02-12 Paolo Bonzini <bonzini@gnu.org> PR sanitizer/84307 * internal-fn.def (ASAN_CHECK): Fix fnspec to account for return value. (ASAN_MARK): Fix fnspec to account for return value, change pointer argument from 'R' to 'W' so that the pointed-to datum is clobbered. gcc/testsuite: 2018-02-12 Paolo Bonzini <bonzini@gnu.org> PR sanitizer/84307 * gcc.dg/asan/pr84307.c: New test. Added: trunk/gcc/testsuite/gcc.dg/asan/pr84307.c Modified: trunk/gcc/ChangeLog trunk/gcc/internal-fn.def trunk/gcc/testsuite/ChangeLog
Author: bonzini Date: Tue Feb 13 13:03:22 2018 New Revision: 257625 URL: https://gcc.gnu.org/viewcvs?rev=257625&root=gcc&view=rev Log: gcc: 2018-02-13 Paolo Bonzini <bonzini@gnu.org> PR sanitizer/84340 * internal-fn.def (ASAN_CHECK, ASAN_MARK): Revert changes to fnspec. gcc/testsuite: 2018-02-13 Paolo Bonzini <bonzini@gnu.org> PR sanitizer/84307 * gcc.dg/asan/pr84307.c: Remove test. Removed: trunk/gcc/testsuite/gcc.dg/asan/pr84307.c Modified: trunk/gcc/ChangeLog trunk/gcc/internal-fn.def trunk/gcc/testsuite/ChangeLog
Patch reverted due to PR84340.
Author: marxin Date: Fri Feb 16 10:03:47 2018 New Revision: 257729 URL: https://gcc.gnu.org/viewcvs?rev=257729&root=gcc&view=rev Log: Set proper internal functions fnspec (PR sanitizer/84307). 2018-02-16 Martin Liska <mliska@suse.cz> PR sanitizer/84307 * internal-fn.def (ASAN_CHECK): Set proper flags. (ASAN_MARK): Likewise. Modified: trunk/gcc/ChangeLog trunk/gcc/internal-fn.def
Author: jakub Date: Wed Apr 25 10:02:24 2018 New Revision: 259641 URL: https://gcc.gnu.org/viewcvs?rev=259641&root=gcc&view=rev Log: PR sanitizer/84307 * c-decl.c (build_compound_literal): Call pushdecl (decl) even when it is not TREE_STATIC. * c-typeck.c (c_mark_addressable) <case COMPOUND_LITERAL_EXPR>: Mark not just the COMPOUND_LITERAL_EXPR node itself addressable, but also its COMPOUND_LITERAL_EXPR_DECL. Modified: trunk/gcc/c/ChangeLog trunk/gcc/c/c-decl.c trunk/gcc/c/c-typeck.c
Jakub: Can the bug be marked as resolved?
Fixed for GCC 9 and later, no plans to backport it.