From eca0503b8ae3c913b7e5aa90a03a8940643aa404 Mon Sep 17 00:00:00 2001 From: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> Date: Mon, 26 Oct 2026 16:12:14 +1100 Subject: [PATCH] interp: an undefined named parameter in a sub definition reads as zero read_named_parameter() skips the "not defined" error while a sub is being defined, but returned without writing the result. The caller's stack variable stayed uninitialized and read_real_value() then tested it for NaN and infinity. On i386 the leftover value is sometimes NaN, so "o# call" inside a sub definition failed with "Calculation resulted in 'not a number'"; tests/interp/oword-bug315-p2 flaked on the i386 CI job this way. Valgrind reports the uninitialized read on x86-64 too. --- src/emc/rs274ngc/interp_namedparams.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/emc/rs274ngc/interp_namedparams.cc b/src/emc/rs274ngc/interp_namedparams.cc index b00c7206c2d..6efa911a465 100644 --- a/src/emc/rs274ngc/interp_namedparams.cc +++ b/src/emc/rs274ngc/interp_namedparams.cc @@ -184,8 +184,10 @@ int Interp::read_named_parameter( } else { // do not require named parameters to be defined during a // subroutine definition: - if (_setup.defining_sub) + if (_setup.defining_sub) { + *double_ptr = 0.0; return INTERP_OK; + } logNP("%s: referencing undefined named parameter '%s' level=%d", name, paramNameBuf, (paramNameBuf[0] == '_') ? 0 : _setup.call_level);