[Bug fortran/125860] UBAN reports member access within null pointer at fortran/interface.cc:4717 since r17-1502-g9d868e49122b4c
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jun 18 12:18:12 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125860
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Jambor <jamborm@gcc.gnu.org>:
https://gcc.gnu.org/g:9d70d3894bda3e6529639e4ae0beb2fe14b9189e
commit r17-1659-g9d70d3894bda3e6529639e4ae0beb2fe14b9189e
Author: Martin Jambor <mjambor@suse.cz>
Date: Thu Jun 18 14:17:14 2026 +0200
fortran: Fix UBSAN error member access within null pointer (PR125860)
With UBSAN instrumented compiler, compiling the testcase
gfortran.dg/altreturn_5.f90 at -O3 fails with:
/home/worker/buildworker/ubsan/build/gcc/fortran/interface.cc:4717:27:
runtime error: member access within null pointer of type 'struct gfc_expr'
This patch adds the necessary guard to avoid passing an invalid LOC to
gfc_value_set_and_used even when the EXPR parameter is NULL and the
function will just return. I have left the NULL-check in
gfc_value_set_and_used intact so that the behavior of the function is
consistent with gfc_value_used_expr (and possibly other functions).
gcc/fortran/ChangeLog:
2026-06-16 Martin Jambor <mjambor@suse.cz>
PR fortran/125860
* interface.cc (gfc_procedure_use): Check a->expr is not NULL
before
calling gfc_value_set_and_used.
More information about the Gcc-bugs
mailing list