https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128316
Bug ID: 128316
Summary: [17 regression] valgrind error in
gfc_get_location_with_offset(locus*, unsigned int)
(error.cc:69)
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: ---
For this Fortran 2008 source code:
1 type ty
2 integer,pointer :: ptr(:)
3 end type
4 type(ty)::obj
5 allocate(obj%ptr(9))
6 obj%ptr = [1,2,3,4,5,6,7,8,9]
7 call sub(obj%ptr)
8
if(any(obj%ptr.ne.[11,12,13,14,15,16,17,18,19]))print*,"101"
9 print*,"pass"
10 contains
11 subroutine sub(dmy)
12 integer,contiguous:: dmy(:)
13 if(any(dmy.ne.[1,2,3,4,5,6,7,8,9])) print*,"106"
14 if(loc(dmy).ne.loc(obj%ptr))print*,"101"
15 dmy = dmy + 10
16 end subroutine
17 end
from the Fujitsu test suite on github, file Fortran/0486/0486_0118.f08,
does this
$ ../results.20261028.valgrind/bin/gfortran -c -w bug1260.f08
==1559552== Invalid read of size 8
==1559552== at 0x4CF4A2: gfc_get_location_with_offset(locus*, unsigned int)
(error.cc:69)
==1559552== by 0x5FDC0F: gfc_get_location (gfortran.h:3732)
==1559552== by 0x5FDC0F: gfc_set_decl_location (trans-decl.cc:329)
==1559552== by 0x5FDC0F: gfc_get_label_decl(gfc_st_label*)
(trans-decl.cc:360)
==1559552== by 0x67BAFC: gfc_trans_label_here(gfc_code*) (trans-stmt.cc:71)
==1559552== by 0x5D505E: trans_code(gfc_code*, tree_node*) (trans.cc:2367)
==1559552== by 0x60E184: gfc_generate_function_code(gfc_namespace*)
(trans-decl.cc:8422)
==1559552== by 0x5607D7: translate_all_program_units (parse.cc:7751)
==1559552== by 0x5607D7: gfc_parse_file() (parse.cc:8081)
==1559552== by 0x5D1F3F: gfc_be_parse_file() (f95-lang.cc:251)
==1559552== by 0xC870A9: compile_file() (toplev.cc:455)
==1559552== by 0x47DB88: do_compile (toplev.cc:2228)
==1559552== by 0x47DB88: toplev::main(int, char**) (toplev.cc:2396)
==1559552== by 0x47F59A: main (main.cc:39)
==1559552== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==1559552==
==1559552==
==1559552== Exit program on first error (--exit-on-first-error=yes)
$
with a recent of trunk gfortran built with valgrind.
Compiler is
$ ~/gcc/results.20261028.valgrind/bin/gfortran -v
Using built-in specs.
COLLECT_GCC=/home/dcb42/gcc/results.20261028.valgrind/bin/gfortran
COLLECT_LTO_WRAPPER=/home/dcb42/gcc/results.20261028.valgrind/libexec/gcc/x86_64-pc-linux-gnu/17.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../trunk/configure
--prefix=/home/dcb42/gcc/results.20261028.valgrind --disable-bootstrap
--disable-doc --disable-fixincludes --disable-multilib
--with-pkgversion=8280b3ff920fc6b1 --enable-checking=valgrind
--enable-languages=c,c++,fortran
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 17.0.0 20261028 (experimental) (8280b3ff920fc6b1)
$