From 5ec65fde0a8d77e2c62699dba5e42399d66ad79d Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 19 Apr 2021 17:39:03 +1200 Subject: [PATCH] Initialise _v to 0 in typecheck case This avoids using _v uninitialised if there's an empty typecheck typemap, such as the dummy one we have for std::initializer_list. Fixes GCC warning on cpp11_initializer_list testcase when compiled with -O2. --- CHANGES.current | 5 +++++ Source/Modules/overload.cxx | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index f0b7a0ff6..aa33c09e9 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2021-04-19: olly + Fix use of uninitialised variable in the generated code for an + empty typecheck typemap, such as the dummy one we include for + std::initializer_list. + 2021-04-12: olly #1777 [Python] Specifying -py3 now generates a check for Python version >= 3.0. diff --git a/Source/Modules/overload.cxx b/Source/Modules/overload.cxx index 5d278107c..512c5da39 100644 --- a/Source/Modules/overload.cxx +++ b/Source/Modules/overload.cxx @@ -809,7 +809,7 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar } if (num_arguments) { - Printf(f, "int _v;\n"); + Printf(f, "int _v = 0;\n"); } int num_braces = 0;