[Bug middle-end/92952] [10 regression] gfortran.dg/lto/pr87689 FAILs at -O2
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Dec 16 18:42:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92952
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2019-12-16
Ever confirmed|0 |1
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
-Wstringop-overflow is enabled only for the C family of languages (and for LTO)
so it shouldn't be issued for Fortran code (see also pr80545). I think the
problem might be making the distinction between languages during LTO builds.
I can reproduce the warning but have no idea how to actually step into the LTO
code. My best guess is that the size computation doesn't account for the
non-zero low bound in Fortran arrays. The following avoids the warning so let
me go with it.
Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c (revision 279443)
+++ gcc/builtins.c (working copy)
@@ -3999,6 +3999,16 @@ compute_objsize (tree dest, int ostype, tree *pdec
above. */
if (TREE_CODE (dest) == ARRAY_REF)
{
+ tree lowbnd = array_ref_low_bound (dest);
+ if (!integer_zerop (lowbnd) && tree_fits_uhwi_p (lowbnd))
+ {
+ /* Adjust the offset by the low bound of the array
+ domain (normally zero but 1 in Fortran). */
+ unsigned HOST_WIDE_INT lb = tree_to_uhwi (lowbnd);
+ offrng[0] -= lb;
+ offrng[1] -= lb;
+ }
+
/* Convert the array index into a byte offset. */
tree eltype = TREE_TYPE (dest);
tree tpsize = TYPE_SIZE_UNIT (eltype);
More information about the Gcc-bugs
mailing list