https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128042
Bug ID: 128042
Summary: valgrind error in gfc_encode_character(int, unsigned
long, unsigned int const*, unsigned char*, unsigned
long) (target-memory.cc:255)
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: dcb314 at hotmail dot com
Target Milestone: ---
Created attachment 65909
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65909&action=edit
fortran source code
The attached fortran code, from the Fujitsu test suite file
Fortran/0316/0316_0097.f does this with recent gfortran,
compiled by valgrind:
$ ~/gcc/results.20261020.valgrind/bin/gfortran -c -w
/home/dcb42/fujitsu/trunk/Fortran/0316/0316_0097.f
==1916800== Invalid read of size 4
==1916800== at 0x5BADE0: poly_int<unsigned int> (poly-int.h:472)
==1916800== by 0x5BADE0: poly_int<unsigned int> (poly-int.h:457)
==1916800== by 0x5BADE0: gfc_encode_character(int, unsigned long, unsigned
int const*, unsigned char*, unsigned long) (target-memory.cc:255)
$ ~/gcc/results.20261020.valgrind/bin/gfortran -v 2>&1 | grep exp
gcc version 17.0.0 20261019 (experimental) (708cc223b0f8b96c)
$
git blame for target-memory.cc:255 says:
d393bbd73754 gcc/fortran/target-memory.c (Francois-Xavier Coudert 2008-05-18
22:45:05 +0000 255) native_encode_expr (build_int_cst (type, string[i]),
&buffer[i*elsize],