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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

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

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Siddhesh Poyarekar from comment #0)
> struct magic_ {
>         char unused[9]; // at least 9
> };
> 
> struct magic_map {
>         struct magic_ *magic;
> };
> 
> static int
> coalesce_entries(struct magic_ **ma)
> {
>   size_t slen;
> 
>   slen = sizeof (**ma);
>   *ma = __builtin_malloc (slen);

But note that in this case even a simple
  foo ();
call here

> 
>   for (unsigned i = 0; i < 1; i++)
>     {
>       char b[1024] = {};

or here

>       struct magic_ *ptr = *ma;
>       (void) __builtin___memcpy_chk (ptr, b, sizeof (*ptr),
>                                      __builtin_dynamic_object_size (ptr, 0));

or in a loop with more than one iteration also here will mean we need to punt,
at least when the coalesce_entries function isn't inlined into caller.  Because
ma pointer
could have been stored e.g. to global variable and foo could have done *ma_copy
= __builtin_malloc (64); or *ma_copy = global_array; etc.

Reply via email to