[Bug fortran/79929] [7 Regression] Bogus Warning: '__builtin_memset': specified size 4294967291 exceeds maximum object size 2147483647
anlauf at gmx dot de
gcc-bugzilla@gcc.gnu.org
Thu Mar 30 19:33:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79929
--- Comment #3 from Harald Anlauf <anlauf at gmx dot de> ---
I've slightly reduced the example to the following:
% cat gfcbug138c.f90
subroutine gfcbug138 (yerrmsg)
character(kind=1,len=*) :: yerrmsg
yerrmsg = 1_"bug: " // yerrmsg
end subroutine gfcbug138
The dump tree now reads:
gfcbug138 (character(kind=1)[1:_yerrmsg] & restrict yerrmsg, integer(kind=4)
_yerrmsg)
{
bitsizetype D.3423;
sizetype D.3424;
D.3423 = (bitsizetype) (sizetype) NON_LVALUE_EXPR <_yerrmsg> * 8;
D.3424 = (sizetype) NON_LVALUE_EXPR <_yerrmsg>;
{
character(kind=1)[1:] * pstr.0;
void * restrict D.3419;
integer(kind=4) D.3420;
integer(kind=4) D.3421;
integer(kind=4) D.3422;
D.3419 = (void * restrict) __builtin_malloc (MAX_EXPR <(character(kind=4))
(_yerrmsg + 5), 1>);
pstr.0 = (character(kind=1)[1:] *) D.3419;
_gfortran_concat_string (_yerrmsg + 5, pstr.0, 5, &"bug: "[1]{lb: 1 sz: 1},
_yerrmsg, yerrmsg);
D.3420 = _yerrmsg + 5;
D.3421 = _yerrmsg + 5;
D.3422 = _yerrmsg;
if (D.3422 != 0)
{
__builtin_memmove ((void *) yerrmsg, (void *) pstr.0, MIN_EXPR
<(character(kind=4)) D.3422, (character(kind=4)) D.3421>);
if ((character(kind=4)) D.3421 < (character(kind=4)) D.3422)
{
__builtin_memset ((void *) yerrmsg + (sizetype) D.3421, 32,
(character(kind=4)) D.3422 - (character(kind=4)) D.3421);
}
}
__builtin_free ((void *) pstr.0);
}
}
- Why are there still occurrences of character(kind=4)? Shouldn't there be
always character(kind=1)?
- The optimizer gets confused by a potential overflow of the length of the
concatenated string (_yerrmsg + 5), which is the only way the memset can be
invoked, with a length of -5, which is less than 0 (assuming ordinary wrapping
integer arithmetic)
More information about the Gcc-bugs
mailing list