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 <[email protected]>:

https://gcc.gnu.org/g:9d70d3894bda3e6529639e4ae0beb2fe14b9189e

commit r17-1659-g9d70d3894bda3e6529639e4ae0beb2fe14b9189e
Author: Martin Jambor <[email protected]>
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  <[email protected]>

            PR fortran/125860
            * interface.cc (gfc_procedure_use): Check a->expr is not NULL
before
            calling gfc_value_set_and_used.

Reply via email to