https://gcc.gnu.org/g:488509e6d4b243e5bda750b2d4b2fd8a80a1572f
commit r17-5533-g488509e6d4b243e5bda750b2d4b2fd8a80a1572f Author: Harald Anlauf <[email protected]> Date: Fri Oct 23 21:27:01 2026 +0200 fortran: Fix invalid read with 'use, only:' [PR128067] PR fortran/128067 gcc/fortran/ChangeLog: * module.cc (load_needed): Prevent scanning of empty name for prefix "__". Diff: --- gcc/fortran/module.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/module.cc b/gcc/fortran/module.cc index 70d231dcf6a2..634af39659c2 100644 --- a/gcc/fortran/module.cc +++ b/gcc/fortran/module.cc @@ -5685,7 +5685,9 @@ load_needed (pointer_info *p) but not used warnings; don't mark internal symbols such as __vtab, __def_init etc. Only mark them if they have been explicitly loaded. */ - if (only_flag && sym->name[0] != '_' && sym->name[1] != '_') + if (only_flag + && sym->name[0] != '\0' + && !(sym->name[0] == '_' && sym->name[1] == '_')) { gfc_use_rename *u;
