From c321d80fddcdedad4b850f46683bd838d909cf3f Mon Sep 17 00:00:00 2001 From: Biswapriyo Nath Date: Sun, 15 May 2022 21:31:12 +0530 Subject: [PATCH] Fix variable initialization due to jump bypassing it This fixes the following error in mingw gcc toolchain. Also clang also have same error. src/_tkagg.cpp:274:26: note: crosses initialization of 'bool tk_ok' 274 | bool tcl_ok = false, tk_ok = false; | ^~~~~ src/_tkagg.cpp:274:10: note: crosses initialization of 'bool tcl_ok' 274 | bool tcl_ok = false, tk_ok = false; | ^~~~~~ According to C++ standard (6.7.3): It is possible to transfer into a block, but not in a way that bypasses declarations with initialization. A program that jumps from a point where a variable with automatic storage duration is not in scope to a point where it is in scope is ill-formed unless the variable has scalar type... --- src/_tkagg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_tkagg.cpp b/src/_tkagg.cpp index 5a5616bea539..a2c99b50486b 100644 --- a/src/_tkagg.cpp +++ b/src/_tkagg.cpp @@ -259,6 +259,7 @@ void load_tkinter_funcs(void) HANDLE process = GetCurrentProcess(); // Pseudo-handle, doesn't need closing. HMODULE* modules = NULL; DWORD size; + bool tcl_ok = false, tk_ok = false; if (!EnumProcessModules(process, NULL, 0, &size)) { PyErr_SetFromWindowsErr(0); goto exit; @@ -271,7 +272,6 @@ void load_tkinter_funcs(void) PyErr_SetFromWindowsErr(0); goto exit; } - bool tcl_ok = false, tk_ok = false; for (unsigned i = 0; i < size / sizeof(HMODULE); ++i) { if (!tcl_ok) { tcl_ok = load_tcl(modules[i]);