https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57965

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #4 from kargl at gcc dot gnu.org ---
The original code compiles and executes.  Adding some debugging
gives

(In reply to Harald Anlauf from comment #3)
> The dump tree of the allocation looks strange:
> 
>   a = (struct mytype *) __builtin_malloc (4);
> ...
>   {
>     struct mytype mytype.0;
> 
>     __builtin_memmove ((void *) mytype.0.str_value, (void *) &0B, 1);
>     __builtin_memset ((void *) mytype.0.str_value + 1, 32, 41);
>     *a = mytype.0;
>   }
> 
> Instead of setting the string's first character to zero,
> the memmove appears to access a null pointer.
> 
> Or am I missing something?

First, the code compiles and executes without a problem.

Second, yes, that looks strange.  a%str_value should be
an unallocated scalar string with a length of 42.  The
__builtin_memmove looks to be setting the a%str_value to
a NULL C pointer, and then blank pads to a length of
42.

Reply via email to