https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84307
Bug ID: 84307
Summary: asan blocks dead-store elimination
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: sanitizer
Assignee: unassigned at gcc dot gnu.org
Reporter: bonzini at gnu dot org
CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at
gcc dot gnu.org
Target Milestone: ---
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;
}