[Bug fortran/124450] [16 Regression] trans-io.cc:2516: runtime error
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Mar 22 05:22:09 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124450
--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:f82124516c3e605ebd4b492a000d02da38ab3bfe
commit r13-10216-gf82124516c3e605ebd4b492a000d02da38ab3bfe
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu Mar 12 12:39:43 2026 +0100
fortran: Fix UB in transfer_expr [PR124450]
trans-io.cc (transfer_array_component) calls transfer_expr with
NULL code:
transfer_expr (&se, &cm->ts, tmp, NULL, NULL_TREE);
I'm surprised it doesn't ICE in other spots that dereference
code->whatever but each one is guarded with some condition
that perhaps don't trigger in that case for some reason.
Anyway, the &code->loc case does trigger, it doesn't ICE, but
it is undefined behavior in the compiler when code is NULL,
and we'd crash if the where argument of 3*sizeof(void*) is
dereferenced. Code I've checked can handle NULL where though.
2026-03-12 Jakub Jelinek <jakub@redhat.com>
PR fortran/124450
* trans-io.cc (transfer_expr): If code is NULL, call
transfer_array_component with NULL where argument rather than
&code->loc.
* gfortran.dg/pr124450.f90: New test.
(cherry picked from commit adefcfed81e19aa250f34914182a7c5580dc6e2a)
More information about the Gcc-bugs
mailing list