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

Siddhesh Poyarekar <siddhesh at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |siddhesh at gcc dot 
gnu.org

--- Comment #5 from Siddhesh Poyarekar <siddhesh at gcc dot gnu.org> ---
I'm not 100% sure if it's invalid code, but I was just about to write that it
depends on what the pass ends up seeing.  If earlier passes end up optimizing
the code such that the objsz pass sees the malloc first (e.g. the reproducer in
pr104961), it ends up with the malloc'd size, otherwise it ends up with the
declared size.

So if it was:

struct bad_struct { 
  struct g          
  {                 
    char s_str[1];  
  } i;              
};                  

and

struct g *i = &bad->i;      
strcpy (i->s_str, "sparta");

then i tends to get optimized as a MEM_REF of the malloc'd block, letting us
see the extra space.

This needs to be fixed, but then it's possibly a different bug from the one
you're seeing in acl since this affects __bos too, not just __bdos.

(I'm off in a couple of hours btw, returning on Tuesday so I may not get to it
until then)

Reply via email to