Message ID | 20150120114907.GG3074@redhat.com |
---|---|
State | New |
Headers | show |
On Tue, Jan 20, 2015 at 12:49:07PM +0100, Marek Polacek wrote: > 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? To 4.9 or 4.8 (subject says 4.8, above is 4.9). I think it would be ok to both. > > 2015-01-20 Marek Polacek <polacek@redhat.com> > > Backport from mainline > 2014-06-23 Marek Polacek <polacek@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. Jakub
On Tue, Jan 20, 2015 at 12:51:45PM +0100, Jakub Jelinek wrote: > On Tue, Jan 20, 2015 at 12:49:07PM +0100, Marek Polacek wrote: > > 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? > > To 4.9 or 4.8 (subject says 4.8, above is 4.9). > I think it would be ok to both. Eek, I meant 4.9. But 4.8 has the same issue, so I've committed the slightly adjusted patch to both 4.9 and 4.8. Marek
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" } */ +}