I have been running all of my extensive tests through valgrind and picking off errors, one by one. I found logic in gcc/real.cc that has an inconsequential read of an uninitialized memory location. This change eliminates that warning.
Is the following patch okay for trunk? >From fffd7c46b2796e5ff98a53b06409f48961e1eb21 Mon Sep 17 00:00:00 2001 From: Robert Dubner <rdub...@symas.com> Date: Thu, 31 Jul 2025 07:45:26 -0400 Subject: [PATCH] real: Eliminate access to uninitialized memory. When compiling this program with gcobol: identification division. program-id. prog. data division. working-storage section. 01 val pic v9(5) value .001. procedure division. display val goback. the rounding up of .99999...9999 to 1.000...0000 causes a read of the first byte of the output buffer. Although harmless, it generates a valgrind warning. The following change clears that warning. gcc/ChangeLog: * real.cc (real_to_decimal_for_mode): Set str[0] to known value. --- gcc/real.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/real.cc b/gcc/real.cc index 1f987d48889..43d25246ed7 100644 --- a/gcc/real.cc +++ b/gcc/real.cc @@ -1629,6 +1629,11 @@ real_to_decimal_for_mode (char *str, const REAL_VALUE_TYPE *r_orig, strcpy (str, (r.sign ? "-0.0" : "0.0")); return; case rvc_normal: + /* When r_orig is a positive value that converts to all nines and is + rounded up to 1.0, str[0] is harmlessly accessed before being set to + '1'. That read access triggers a valgrind warning. Setting str[0] + to any value quiets the warning. */ + str[0] = ' '; break; case rvc_inf: strcpy (str, (r.sign ? "-Inf" : "+Inf")); -- 2.34.1