ICE with atomic_store
Andrew MacLeod
amacleod@redhat.com
Wed Jun 18 18:04:00 GMT 2014
On 06/18/2014 12:59 PM, Basile Starynkevitch wrote:
> Hello All,
>
> The following code:
>
> #include <stdlib.h>
> struct s1_st {
> char* i_name;
> struct s1_st* i_foo;
> };
>
> void clear_s1 (struct s1_st*s)
> {
> __atomic_store(s->i_name, NULL, __ATOMIC_SEQ_CST);
> }
>
> gives an ICE when compiled (on Debian/Sid/amd64) by GCC 4.8 & 4.9 (I did not test it on the trunk yet)
>
> (For some strange reason, probably on my side, I'm not able to change the password on bugzilla. So I'm reporting that bug here, sorry for the inconvenience).
>
> Cheers.
>
First, thats an error... the second parameter to __atomic_store must be
a pointer to memory, not NULL. We store the contents of that location to
s->i_name. Perhaps it was meant to be __atomic_store_n () ?
That doesn't excuse the exception however. Looks like void type has a
NULL TYPE_SIZE_UNIT, which causes tree_to_uhwi to segfault. could be
fixed with something like this.. try it. I get
a.c: In function ‘clear_s1’:
a.c:9:6: error: size mismatch in argument 2 of ‘__atomic_store’
__atomic_store(s->i_name, NULL, __ATOMIC_SEQ_CST);
Thoroughly untested of course :-)
Andrew
-------------- next part --------------
* c-common,c (get_atomic_generic_size): Handle pointer to 0 size.
Index: c-family/c-common.c
===================================================================
*** c-family/c-common.c (revision 211758)
--- c-family/c-common.c (working copy)
*************** get_atomic_generic_size (location_t loc,
*** 10462,10467 ****
--- 10462,10468 ----
{
int size;
tree type = TREE_TYPE ((*params)[x]);
+ tree type_size;
/* __atomic_compare_exchange has a bool in the 4th position, skip it. */
if (n_param == 6 && x == 3)
continue;
*************** get_atomic_generic_size (location_t loc,
*** 10471,10477 ****
function);
return 0;
}
! size = tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (type)));
if (size != size_0)
{
error_at (loc, "size mismatch in argument %d of %qE", x + 1,
--- 10472,10480 ----
function);
return 0;
}
!
! 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,
More information about the Gcc
mailing list