This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ICE with atomic_store


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



Attachment: PP
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]