https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81879
--- Comment #1 from Frediano Ziglio <freddy77 at gmail dot com> --- This is weird. If after the x86_64-w64-mingw32-g++ -flto -O2 -g -save-temps -Wall -Werror -Wextra -static -mconsole -o test.exe test.cpp command I run x86_64-w64-mingw32-g++ -v test.exe.ltrans0.s -static -o test.exe -mconsole the executable I get is able to run. Trying to find some difference between the executables I found that the widen call is different, specifically in one case (the one crashing) do_widen is not generated. Quite weird that in the wrong code %rdx is assigned to a pointer inside a function while in the working case a valid pointer to a function is used. @@ -49312,7 +49312,7 @@ ---: 89 d6 mov %edx,%esi ---: e8 c0 fa ff ff callq 4275e0 <std::ctype<char>::_M_widen_init() const> ---: 48 8b 03 mov (%rbx),%rax ----: 48 8d 15 46 00 00 00 lea 0x46(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 427b2a <std::ctype<char>::widen(char) const [clone .part.23]+0x1a> ---: 48 8b 40 30 mov 0x30(%rax),%rax ---: 48 39 d0 cmp %rdx,%rax ---: 75 0d jne 427b40 <std::ctype<char>::widen(char) const [clone .part.23]+0x30> @@ -49345,30 +49345,13 @@ ---: 90 nop ---: 90 nop -0000000000427b70 <std::ctype<char>::do_widen(char) const>: ----: 89 d0 mov %edx,%eax ----: c3 retq ----: 90 nop ----: 90 nop ----: 90 nop ----: 90 nop ----: 90 nop ----: 90 nop ----: 90 nop ----: 90 nop ----: 90 nop ----: 90 nop ----: 90 nop ----: 90 nop ----: 90 nop