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

--- Comment #16 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #15)
> The warning only sees the four byte write at the end:
> 
>   MEM[(int *)&D.3146 + 4B] = 24;   <<< write past the end

That stmt has all the info that it is a store of 4 bytes at offset 4 into an
object of size 4, so there is no reason why the warning shouldn't see that.

> I will disable it but my main concern was with the char array: is it valid
> to transform a 1-element int array in the source into a 4-byte char array
> like this?  (If it is valid in general, warnings issued by LTO that
> reference source code decls will be confusing if they mention different
> types than they were declared with.)

The 4-byte char array is of course valid, it is created by 
fold_builtin_alloca_with_align when it sees alloca with constant size below the
threshold.  And it has nothing to do with LTO, as I said, just use
-fwhole-program instead of -flto and you'll see the same (or make f
always_inline inline function).

Reply via email to