I'd like to backport this patch from trunk to 4.9 so as to fix PR63751. It's safe and has been on trunk for several months.
Bootstrapped/regtested on x86_64-linux, ok? 2015-01-20 Marek Polacek <pola...@redhat.com> Backport from mainline 2014-06-23 Marek Polacek <pola...@redhat.com> PR c/61553 * c-common.c (get_atomic_generic_size): Don't segfault if the type doesn't have a size. * c-c++-common/pr61553.c: New test. diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c index 487fb4e..8856701 100644 --- gcc/c-family/c-common.c +++ gcc/c-family/c-common.c @@ -10402,7 +10402,8 @@ get_atomic_generic_size (location_t loc, tree function, function); return 0; } - size = tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (type))); + tree type_size = TYPE_SIZE_UNIT (TREE_TYPE (type)); + size = type_size ? tree_to_uhwi (type_size) : 0; if (size != size_0) { error_at (loc, "size mismatch in argument %d of %qE", x + 1, diff --git gcc/testsuite/c-c++-common/pr61553.c gcc/testsuite/c-c++-common/pr61553.c index e69de29..8a3b699 100644 --- gcc/testsuite/c-c++-common/pr61553.c +++ gcc/testsuite/c-c++-common/pr61553.c @@ -0,0 +1,8 @@ +/* PR c/61553 */ +/* { dg-do compile } */ + +void +foo (char *s) +{ + __atomic_store (s, (void *) 0, __ATOMIC_SEQ_CST); /* { dg-error "size mismatch" } */ +} Marek