Re: [PATCH] fortran: Fix UBSAN error member access within null pointer (PR125860)

Thomas Koenig <[email protected]> Wed, 17 Jun 2026 20:56:10 +0200
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.fortran
Message-ID <[email protected]>
Hi Martin,

>    /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) but
> it seems like it could be removed.
> 
> Bootstrapped and tested on x86_64-linux, I have also verified the UBSAN
> failure is gone with this patch.
> 
> OK for master?

OK, and thanks for catching and fixing it.

(Also a very serious candidate for "obvious and simple", if you ask me :-)

Best regards

	Thomas