https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81879
--- Comment #2 from Frediano Ziglio <freddy77 at gmail dot com> --- It seems that this do_widen replacement with an invalid pointer goes on and on, looking at differences in the generated executable: -- ---: 00 00 ---: 48 8b 10 mov (%rax),%rdx ---: 4c 8b 5a 30 mov 0x30(%rdx),%r11 ----: 48 8d 15 2a 65 ff ff lea -0x9ad6(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 431636 <std::__cxx11::time_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::get(std::istreambuf_iterator<char, std::char_traits<char> >, std::istreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, std::_Ios_Iostate&, tm*, char const*, char const*) const+0x6e6> ---: 49 39 d3 cmp %rdx,%r11 ----: 0f 84 ba fc ff ff je 431309 <std::__cxx11::time_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::get(std::istreambuf_iterator<char, std::char_traits<char> >, std::istreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, std::_Ios_Iostate&, tm*, char const*, char const*) const+0x3a9> -- ---: 48 89 44 24 60 mov %rax,0x60(%rsp) ---: callq <std::ctype<char>::_M_widen_init() const> ---: 48 8b 44 24 60 mov 0x60(%rsp),%rax ----: 48 8d 0d a2 5f ff ff lea -0xa05e(%rip),%rcx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 0d 00 00 00 00 lea 0x0(%rip),%rcx # 431bbe <std::__cxx11::time_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::get(std::istreambuf_iterator<char, std::char_traits<char> >, std::istreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, std::_Ios_Iostate&, tm*, char, char) const+0x23e> ---: 4c 8b 44 24 68 mov 0x68(%rsp),%r8 ---: 48 8b 10 mov (%rax),%rdx -- ---: 48 89 44 24 48 mov %rax,0x48(%rsp) ---: callq <std::ctype<char>::_M_widen_init() const> ---: 48 8b 44 24 48 mov 0x48(%rsp),%rax ----: 48 8d 0d e7 5c ff ff lea -0xa319(%rip),%rcx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 0d 00 00 00 00 lea 0x0(%rip),%rcx # 431e79 <std::__cxx11::time_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::do_get(std::istreambuf_iterator<char, std::char_traits<char> >, std::istreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, std::_Ios_Iostate&, tm*, char, char) const+0x1d9> ---: 48 8b 10 mov (%rax),%rdx ---: 4c 8b 42 30 mov 0x30(%rdx),%r8 -- ---: 44 0f b6 54 24 6f movzbl 0x6f(%rsp),%r10d ---: 48 8b 10 mov (%rax),%rdx ---: 4c 8b 5a 30 mov 0x30(%rdx),%r11 ----: 48 8d 15 ef eb fc ff lea -0x31411(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 458f71 <std::time_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::get(std::istreambuf_iterator<char, std::char_traits<char> >, std::istreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, std::_Ios_Iostate&, tm*, char const*, char const*) const+0x6d1> ---: 49 39 d3 cmp %rdx,%r11 ----: 0f 84 d2 fb ff ff je 458b5c <std::time_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::get(std::istreambuf_iterator<char, std::char_traits<char> >, std::istreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, std::_Ios_Iostate&, tm*, char const*, char const*) const+0x2ac> -- ---: 48 89 44 24 58 mov %rax,0x58(%rsp) ---: callq <std::ctype<char>::_M_widen_init() const> ---: 48 8b 44 24 58 mov 0x58(%rsp),%rax ----: 48 8d 0d f5 e7 fc ff lea -0x3180b(%rip),%rcx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 0d 00 00 00 00 lea 0x0(%rip),%rcx # 45936b <std::time_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::get(std::istreambuf_iterator<char, std::char_traits<char> >, std::istreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, std::_Ios_Iostate&, tm*, char, char) const+0x1eb> ---: 48 8b 10 mov (%rax),%rdx ---: 4c 8b 42 30 mov 0x30(%rdx),%r8 -- ---: 48 89 44 24 48 mov %rax,0x48(%rsp) ---: callq <std::ctype<char>::_M_widen_init() const> ---: 48 8b 44 24 48 mov 0x48(%rsp),%rax ----: 48 8d 0d 97 e5 fc ff lea -0x31a69(%rip),%rcx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 0d 00 00 00 00 lea 0x0(%rip),%rcx # 4595c9 <std::time_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::do_get(std::istreambuf_iterator<char, std::char_traits<char> >, std::istreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, std::_Ios_Iostate&, tm*, char, char) const+0x1d9> ---: 48 8b 10 mov (%rax),%rdx ---: 4c 8b 42 30 mov 0x30(%rdx),%r8 -- ---: 48 89 d9 mov %rbx,%rcx ---: callq <std::ctype<char>::_M_widen_init() const> ---: 48 8b 03 mov (%rbx),%rax ----: 48 8d 15 ea a9 fc ff lea -0x35616(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 45d176 <std::time_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::do_put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, tm const*, char, char) const+0x146> ---: 4c 8b 40 30 mov 0x30(%rax),%r8 ---: b8 25 00 00 00 mov $0x25,%eax -- ---: 48 89 f1 mov %rsi,%rcx ---: callq <std::ctype<char>::_M_widen_init() const> ---: 48 8b 06 mov (%rsi),%rax ----: 48 8d 15 ce a5 fc ff lea -0x35a32(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 45d592 <std::basic_ios<char, std::char_traits<char> >::fill() const+0x62> ---: 4c 8b 40 30 mov 0x30(%rax),%r8 ---: b8 20 00 00 00 mov $0x20,%eax -- ---: callq <std::ctype<char>::_M_widen_init() const> ---: 48 8b 03 mov (%rbx),%rax ---: 8b 54 24 2c mov 0x2c(%rsp),%edx ----: 48 8d 0d 41 a5 fc ff lea -0x35abf(%rip),%rcx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 0d 00 00 00 00 lea 0x0(%rip),%rcx # 45d61f <std::basic_ios<char, std::char_traits<char> >::widen(char) const+0x3f> ---: 4c 8b 40 30 mov 0x30(%rax),%r8 ---: 89 d0 mov %edx,%eax -- ---: 4c 89 44 24 28 mov %r8,0x28(%rsp) ---: callq <std::ctype<char>::_M_widen_init() const> ---: 48 8b 03 mov (%rbx),%rax ----: 48 8d 15 19 19 fc ff lea -0x3e6e7(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 466247 <std::istream::get(char*, long long)+0x57> ---: 41 b9 0a 00 00 00 mov $0xa,%r9d ---: 4c 8b 44 24 28 mov 0x28(%rsp),%r8 -- ---: 48 89 d9 mov %rbx,%rcx ---: callq <std::ctype<char>::_M_widen_init() const> ---: 48 8b 03 mov (%rbx),%rax ----: 48 8d 15 8e 16 fc ff lea -0x3e972(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 4664d2 <std::istream::get(std::basic_streambuf<char, std::char_traits<char> >&)+0x52> ---: 41 b8 0a 00 00 00 mov $0xa,%r8d ---: 48 8b 40 30 mov 0x30(%rax),%rax -- ---: 4c 89 44 24 28 mov %r8,0x28(%rsp) ---: callq <std::ctype<char>::_M_widen_init() const> ---: 48 8b 03 mov (%rbx),%rax ----: 48 8d 15 b9 ff fb ff lea -0x40047(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 467ba7 <std::istream::getline(char*, long long)+0x57> ---: 41 b9 0a 00 00 00 mov $0xa,%r9d ---: 4c 8b 44 24 28 mov 0x28(%rsp),%r8 -- ---: 4c 89 e9 mov %r13,%rcx ---: callq <std::ctype<char>::_M_widen_init() const> ---: 49 8b 45 00 mov 0x0(%r13),%rax ----: 48 8d 15 fd e5 fb ff lea -0x41a03(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 469563 <std::ostream& std::ostream::_M_insert<void const*>(void const*)+0x153> ---: 41 b8 20 00 00 00 mov $0x20,%r8d ---: 4c 8b 48 30 mov 0x30(%rax),%r9 -- ---: 4c 89 e9 mov %r13,%rcx ---: callq <std::ctype<char>::_M_widen_init() const> ---: 49 8b 45 00 mov 0x0(%r13),%rax ----: 48 8d 0d dd e3 fb ff lea -0x41c23(%rip),%rcx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 0d 00 00 00 00 lea 0x0(%rip),%rcx # 469783 <std::ostream& std::ostream::_M_insert<bool>(bool)+0x153> ---: ba 20 00 00 00 mov $0x20,%edx ---: 4c 8b 40 30 mov 0x30(%rax),%r8 -- ---: 4c 89 e1 mov %r12,%rcx ---: callq <std::ctype<char>::_M_widen_init() const> ---: 49 8b 04 24 mov (%r12),%rax ----: 48 8d 15 cb e1 fb ff lea -0x41e35(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 469995 <std::ostream& std::ostream::_M_insert<double>(double)+0x155> ---: 41 b8 20 00 00 00 mov $0x20,%r8d ---: 4c 8b 48 30 mov 0x30(%rax),%r9 -- ---: 4c 89 e1 mov %r12,%rcx ---: callq <std::ctype<char>::_M_widen_init() const> ---: 49 8b 04 24 mov (%r12),%rax ----: 48 8d 15 9d df fb ff lea -0x42063(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 469bc3 <std::ostream& std::ostream::_M_insert<long double>(long double)+0x163> ---: 41 b8 20 00 00 00 mov $0x20,%r8d ---: 4c 8b 48 30 mov 0x30(%rax),%r9 -- ---: 4c 89 e9 mov %r13,%rcx ---: callq <std::ctype<char>::_M_widen_init() const> ---: 49 8b 45 00 mov 0x0(%r13),%rax ----: 48 8d 15 7d dd fb ff lea -0x42283(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 469de3 <std::ostream& std::ostream::_M_insert<long>(long)+0x153> ---: 41 b8 20 00 00 00 mov $0x20,%r8d ---: 4c 8b 48 30 mov 0x30(%rax),%r9 -- ---: 4c 89 e9 mov %r13,%rcx ---: callq <std::ctype<char>::_M_widen_init() const> ---: 49 8b 45 00 mov 0x0(%r13),%rax ----: 48 8d 15 5d db fb ff lea -0x424a3(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 46a003 <std::ostream& std::ostream::_M_insert<unsigned long>(unsigned long)+0x153> ---: 41 b8 20 00 00 00 mov $0x20,%r8d ---: 4c 8b 48 30 mov 0x30(%rax),%r9 -- ---: 4c 89 e9 mov %r13,%rcx ---: callq <std::ctype<char>::_M_widen_init() const> ---: 49 8b 45 00 mov 0x0(%r13),%rax ----: 48 8d 15 3d d9 fb ff lea -0x426c3(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 46a223 <std::ostream& std::ostream::_M_insert<long long>(long long)+0x153> ---: 41 b8 20 00 00 00 mov $0x20,%r8d ---: 4c 8b 48 30 mov 0x30(%rax),%r9 -- ---: 4c 89 e9 mov %r13,%rcx ---: callq <std::ctype<char>::_M_widen_init() const> ---: 49 8b 45 00 mov 0x0(%r13),%rax ----: 48 8d 15 1d d7 fb ff lea -0x428e3(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 46a443 <std::ostream& std::ostream::_M_insert<unsigned long long>(unsigned long long)+0x153> ---: 41 b8 20 00 00 00 mov $0x20,%r8d ---: 4c 8b 48 30 mov 0x30(%rax),%r9 -- ---: 4c 89 4c 24 28 mov %r9,0x28(%rsp) ---: callq <std::ctype<char>::_M_widen_init() const> ---: 49 8b 45 00 mov 0x0(%r13),%rax ----: 48 8d 15 b5 aa f9 ff lea -0x6554b(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 48d0ab <std::__pad<char, std::char_traits<char> >::_S_pad(std::ios_base&, char, char*, char const*, long long, long long)+0x19b> ---: 4c 8b 4c 24 28 mov 0x28(%rsp),%r9 ---: 4c 8b 40 30 mov 0x30(%rax),%r8 -- ---: 48 89 f9 mov %rdi,%rcx ---: callq <std::ctype<char>::_M_widen_init() const> ---: 48 8b 07 mov (%rdi),%rax ----: 48 8d 15 de b2 f8 ff lea -0x74d22(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 49c882 <std::basic_ios<char, std::char_traits<char> >::fill(char)+0x72> ---: 4c 8b 40 30 mov 0x30(%rax),%r8 ---: b8 20 00 00 00 mov $0x20,%eax -- ---: 48 89 e9 mov %rbp,%rcx ---: callq <std::ctype<char>::_M_widen_init() const> ---: 48 8b 45 00 mov 0x0(%rbp),%rax ----: 48 8d 15 7d ad f8 ff lea -0x75283(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 49cde3 <std::basic_ios<char, std::char_traits<char> >::copyfmt(std::basic_ios<char, std::char_traits<char> > const&)+0x233> ---: 48 8b 40 30 mov 0x30(%rax),%rax ---: 48 39 d0 cmp %rdx,%rax -- ---: bf 20 00 00 00 mov $0x20,%edi ---: callq <std::ctype<char>::_M_widen_init() const> ---: 48 8b 45 00 mov 0x0(%rbp),%rax ----: 48 8d 15 48 ad f8 ff lea -0x752b8(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 49ce18 <std::basic_ios<char, std::char_traits<char> >::copyfmt(std::basic_ios<char, std::char_traits<char> > const&)+0x268> ---: 48 8b 40 30 mov 0x30(%rax),%rax ---: 48 39 d0 cmp %rdx,%rax -- ---: 4c 89 f1 mov %r14,%rcx ---: callq <std::ctype<char>::_M_widen_init() const> ---: 49 8b 06 mov (%r14),%rax ----: 48 8d 15 b8 91 f8 ff lea -0x76e48(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 49e9a8 <std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long long)+0x2d8> ---: 41 be 20 00 00 00 mov $0x20,%r14d ---: 48 8b 40 30 mov 0x30(%rax),%rax -- ---: 48 89 f9 mov %rdi,%rcx ---: callq <std::ctype<char>::_M_widen_init() const> ---: 48 8b 07 mov (%rdi),%rax ----: 48 8d 15 0e 91 f8 ff lea -0x76ef2(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 49ea52 <std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long long)+0x382> ---: 48 8b 40 30 mov 0x30(%rax),%rax ---: 48 39 d0 cmp %rdx,%rax -- ---: 48 89 d9 mov %rbx,%rcx ---: callq <std::ctype<char>::_M_widen_init() const> ---: 48 8b 03 mov (%rbx),%rax ----: 48 8d 0d 8e 81 f8 ff lea -0x77e72(%rip),%rcx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 0d 00 00 00 00 lea 0x0(%rip),%rcx # 49f9d2 <std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)+0x52> ---: ba 0a 00 00 00 mov $0xa,%edx ---: 48 8b 40 30 mov 0x30(%rax),%rax -- ---: 48 89 e9 mov %rbp,%rcx ---: callq <std::ctype<char>::_M_widen_init() const> ---: 48 8b 45 00 mov 0x0(%rbp),%rax ----: 48 8d 15 9d 5e f8 ff lea -0x7a163(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 4a1cc3 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::_Setfill<char>)+0x63> ---: 48 8b 40 30 mov 0x30(%rax),%rax ---: 48 39 d0 cmp %rdx,%rax -- ---: 48 89 e9 mov %rbp,%rcx ---: callq <std::ctype<char>::_M_widen_init() const> ---: 48 8b 45 00 mov 0x0(%rbp),%rax ----: 48 8d 15 2d 4f f8 ff lea -0x7b0d3(%rip),%rdx # 427b70 <std::ctype<char>::do_widen(char) const> +---: 48 8d 15 00 00 00 00 lea 0x0(%rip),%rdx # 4a2c33 <std::basic_istream<char, std::char_traits<char> >& std::operator>><char, std::char_traits<char> >(std::basic_istream<char, std::char_traits<char> >&, std::_Setfill<char>)+0x63> ---: 48 8b 40 30 mov 0x30(%rax),%rax ---: 48 39 d0 cmp %rdx,%rax So looks like all references to "std::ctype<char>::do_widen(char) const" are replaced with %rip address. Note that resulting executable have no relocations so this is the executed code.