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.
This commit is contained in:
Olly Betts 2021-04-19 17:39:03 +12:00
parent 3912c572ff
commit 5ec65fde0a
2 changed files with 6 additions and 1 deletions

View File

@ -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.

View File

@ -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;