https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105616
Bug ID: 105616 Summary: Using regex_replace throws "maybe-uninitialized" warnings Product: gcc Version: 12.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: christian.morales.vega at gmail dot com Target Milestone: --- As can be seen in https://godbolt.org/z/qK976bqzf Building -------------------- #include <iostream> #include <iterator> #include <regex> #include <string> int main() { std::string text = "Quick brown fox"; std::regex vowel_re("a|e|i|o|u"); // write the results to an output iterator std::regex_replace(std::ostreambuf_iterator<char>(std::cout), text.begin(), text.end(), vowel_re, "*"); // construct a string holding the results std::cout << '\n' << std::regex_replace(text, vowel_re, "[$&]") << '\n'; } -------------------- (taken from https://en.cppreference.com/w/cpp/regex/regex_replace) with "-fsanitize=address -O1 -Wmaybe-uninitialized" creates a long list of warnings -------------------- In file included from /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/regex:48, from <source>:3: In constructor 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]', inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_subexpr_end() [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:290:24: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:405:42: warning: '*(std::function<bool(char)>*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::function<bool(char)>::_M_invoker' may be used uninitialized [-Wmaybe-uninitialized] 405 | : _Function_base(), _M_invoker(__x._M_invoker) | ~~~~^~~~~~~~~~ In file included from /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/regex:63: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h: In member function 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_subexpr_end() [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:287:17: note: '__tmp' declared here 287 | _StateT __tmp(_S_opcode_subexpr_end); | ^~~~~ In member function 'bool std::_Function_base::_M_empty() const', inlined from 'std::function<_Res(_ArgTypes ...)>::operator bool() const [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:574:25, inlined from 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:407:6, inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_subexpr_end() [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:290:24: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:247:37: warning: '*(const std::_Function_base*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::_Function_base::_M_manager' may be used uninitialized [-Wmaybe-uninitialized] 247 | bool _M_empty() const { return !_M_manager; } | ^~~~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h: In member function 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_subexpr_end() [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:287:17: note: '__tmp' declared here 287 | _StateT __tmp(_S_opcode_subexpr_end); | ^~~~~ In constructor 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]', inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_subexpr_begin() [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:281:24: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:405:42: warning: '*(std::function<bool(char)>*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::function<bool(char)>::_M_invoker' may be used uninitialized [-Wmaybe-uninitialized] 405 | : _Function_base(), _M_invoker(__x._M_invoker) | ~~~~^~~~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h: In member function 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_subexpr_begin() [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:279:17: note: '__tmp' declared here 279 | _StateT __tmp(_S_opcode_subexpr_begin); | ^~~~~ In member function 'bool std::_Function_base::_M_empty() const', inlined from 'std::function<_Res(_ArgTypes ...)>::operator bool() const [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:574:25, inlined from 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:407:6, inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_subexpr_begin() [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:281:24: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:247:37: warning: '*(const std::_Function_base*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::_Function_base::_M_manager' may be used uninitialized [-Wmaybe-uninitialized] 247 | bool _M_empty() const { return !_M_manager; } | ^~~~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h: In member function 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_subexpr_begin() [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:279:17: note: '__tmp' declared here 279 | _StateT __tmp(_S_opcode_subexpr_begin); | ^~~~~ In constructor 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]', inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_backref(std::size_t) [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.tcc:173:29: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:405:42: warning: '*(std::function<bool(char)>*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::function<bool(char)>::_M_invoker' may be used uninitialized [-Wmaybe-uninitialized] 405 | : _Function_base(), _M_invoker(__x._M_invoker) | ~~~~^~~~~~~~~~ In file included from /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:400: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.tcc: In member function 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_backref(std::size_t) [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.tcc:171:15: note: '__tmp' declared here 171 | _StateT __tmp(_S_opcode_backref); | ^~~~~ In member function 'bool std::_Function_base::_M_empty() const', inlined from 'std::function<_Res(_ArgTypes ...)>::operator bool() const [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:574:25, inlined from 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:407:6, inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_backref(std::size_t) [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.tcc:173:29: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:247:37: warning: '*(const std::_Function_base*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::_Function_base::_M_manager' may be used uninitialized [-Wmaybe-uninitialized] 247 | bool _M_empty() const { return !_M_manager; } | ^~~~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.tcc: In member function 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_backref(std::size_t) [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.tcc:171:15: note: '__tmp' declared here 171 | _StateT __tmp(_S_opcode_backref); | ^~~~~ In constructor 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]', inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_repeat(std::__detail::_StateIdT, std::__detail::_StateIdT, bool) [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:263:24, inlined from 'bool std::__detail::_Compiler<_TraitsT>::_M_quantifier() [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_compiler.tcc:189:15: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:405:42: warning: '*(std::function<bool(char)>*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::function<bool(char)>::_M_invoker' may be used uninitialized [-Wmaybe-uninitialized] 405 | : _Function_base(), _M_invoker(__x._M_invoker) | ~~~~^~~~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h: In member function 'bool std::__detail::_Compiler<_TraitsT>::_M_quantifier() [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:257:17: note: '__tmp' declared here 257 | _StateT __tmp(_S_opcode_repeat); | ^~~~~ In member function 'bool std::_Function_base::_M_empty() const', inlined from 'std::function<_Res(_ArgTypes ...)>::operator bool() const [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:574:25, inlined from 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:407:6, inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_repeat(std::__detail::_StateIdT, std::__detail::_StateIdT, bool) [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:263:24, inlined from 'bool std::__detail::_Compiler<_TraitsT>::_M_quantifier() [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_compiler.tcc:189:15: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:247:37: warning: '*(const std::_Function_base*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::_Function_base::_M_manager' may be used uninitialized [-Wmaybe-uninitialized] 247 | bool _M_empty() const { return !_M_manager; } | ^~~~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h: In member function 'bool std::__detail::_Compiler<_TraitsT>::_M_quantifier() [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:257:17: note: '__tmp' declared here 257 | _StateT __tmp(_S_opcode_repeat); | ^~~~~ In constructor 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]', inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_repeat(std::__detail::_StateIdT, std::__detail::_StateIdT, bool) [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:263:24, inlined from 'bool std::__detail::_Compiler<_TraitsT>::_M_quantifier() [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_compiler.tcc:199:17: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:405:42: warning: '*(std::function<bool(char)>*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::function<bool(char)>::_M_invoker' may be used uninitialized [-Wmaybe-uninitialized] 405 | : _Function_base(), _M_invoker(__x._M_invoker) | ~~~~^~~~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h: In member function 'bool std::__detail::_Compiler<_TraitsT>::_M_quantifier() [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:257:17: note: '__tmp' declared here 257 | _StateT __tmp(_S_opcode_repeat); | ^~~~~ In member function 'bool std::_Function_base::_M_empty() const', inlined from 'std::function<_Res(_ArgTypes ...)>::operator bool() const [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:574:25, inlined from 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:407:6, inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_repeat(std::__detail::_StateIdT, std::__detail::_StateIdT, bool) [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:263:24, inlined from 'bool std::__detail::_Compiler<_TraitsT>::_M_quantifier() [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_compiler.tcc:199:17: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:247:37: warning: '*(const std::_Function_base*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::_Function_base::_M_manager' may be used uninitialized [-Wmaybe-uninitialized] 247 | bool _M_empty() const { return !_M_manager; } | ^~~~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h: In member function 'bool std::__detail::_Compiler<_TraitsT>::_M_quantifier() [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:257:17: note: '__tmp' declared here 257 | _StateT __tmp(_S_opcode_repeat); | ^~~~~ In constructor 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]', inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_repeat(std::__detail::_StateIdT, std::__detail::_StateIdT, bool) [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:263:24, inlined from 'bool std::__detail::_Compiler<_TraitsT>::_M_quantifier() [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_compiler.tcc:208:15: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:405:42: warning: '*(std::function<bool(char)>*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::function<bool(char)>::_M_invoker' may be used uninitialized [-Wmaybe-uninitialized] 405 | : _Function_base(), _M_invoker(__x._M_invoker) | ~~~~^~~~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h: In member function 'bool std::__detail::_Compiler<_TraitsT>::_M_quantifier() [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:257:17: note: '__tmp' declared here 257 | _StateT __tmp(_S_opcode_repeat); | ^~~~~ In member function 'bool std::_Function_base::_M_empty() const', inlined from 'std::function<_Res(_ArgTypes ...)>::operator bool() const [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:574:25, inlined from 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:407:6, inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_repeat(std::__detail::_StateIdT, std::__detail::_StateIdT, bool) [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:263:24, inlined from 'bool std::__detail::_Compiler<_TraitsT>::_M_quantifier() [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_compiler.tcc:208:15: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:247:37: warning: '*(const std::_Function_base*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::_Function_base::_M_manager' may be used uninitialized [-Wmaybe-uninitialized] 247 | bool _M_empty() const { return !_M_manager; } | ^~~~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h: In member function 'bool std::__detail::_Compiler<_TraitsT>::_M_quantifier() [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:257:17: note: '__tmp' declared here 257 | _StateT __tmp(_S_opcode_repeat); | ^~~~~ In constructor 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]', inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_repeat(std::__detail::_StateIdT, std::__detail::_StateIdT, bool) [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:263:24, inlined from 'bool std::__detail::_Compiler<_TraitsT>::_M_quantifier() [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_compiler.tcc:246:19: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:405:42: warning: '*(std::function<bool(char)>*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::function<bool(char)>::_M_invoker' may be used uninitialized [-Wmaybe-uninitialized] 405 | : _Function_base(), _M_invoker(__x._M_invoker) | ~~~~^~~~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h: In member function 'bool std::__detail::_Compiler<_TraitsT>::_M_quantifier() [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:257:17: note: '__tmp' declared here 257 | _StateT __tmp(_S_opcode_repeat); | ^~~~~ In member function 'bool std::_Function_base::_M_empty() const', inlined from 'std::function<_Res(_ArgTypes ...)>::operator bool() const [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:574:25, inlined from 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:407:6, inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_repeat(std::__detail::_StateIdT, std::__detail::_StateIdT, bool) [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:263:24, inlined from 'bool std::__detail::_Compiler<_TraitsT>::_M_quantifier() [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_compiler.tcc:246:19: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:247:37: warning: '*(const std::_Function_base*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::_Function_base::_M_manager' may be used uninitialized [-Wmaybe-uninitialized] 247 | bool _M_empty() const { return !_M_manager; } | ^~~~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h: In member function 'bool std::__detail::_Compiler<_TraitsT>::_M_quantifier() [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:257:17: note: '__tmp' declared here 257 | _StateT __tmp(_S_opcode_repeat); | ^~~~~ In constructor 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]', inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_repeat(std::__detail::_StateIdT, std::__detail::_StateIdT, bool) [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:263:24, inlined from 'bool std::__detail::_Compiler<_TraitsT>::_M_quantifier() [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_compiler.tcc:264:42: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:405:42: warning: '*(std::function<bool(char)>*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::function<bool(char)>::_M_invoker' may be used uninitialized [-Wmaybe-uninitialized] 405 | : _Function_base(), _M_invoker(__x._M_invoker) | ~~~~^~~~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h: In member function 'bool std::__detail::_Compiler<_TraitsT>::_M_quantifier() [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:257:17: note: '__tmp' declared here 257 | _StateT __tmp(_S_opcode_repeat); | ^~~~~ In member function 'bool std::_Function_base::_M_empty() const', inlined from 'std::function<_Res(_ArgTypes ...)>::operator bool() const [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:574:25, inlined from 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:407:6, inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_repeat(std::__detail::_StateIdT, std::__detail::_StateIdT, bool) [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:263:24, inlined from 'bool std::__detail::_Compiler<_TraitsT>::_M_quantifier() [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_compiler.tcc:264:42: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:247:37: warning: '*(const std::_Function_base*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::_Function_base::_M_manager' may be used uninitialized [-Wmaybe-uninitialized] 247 | bool _M_empty() const { return !_M_manager; } | ^~~~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h: In member function 'bool std::__detail::_Compiler<_TraitsT>::_M_quantifier() [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:257:17: note: '__tmp' declared here 257 | _StateT __tmp(_S_opcode_repeat); | ^~~~~ In constructor 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]', inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_alt(std::__detail::_StateIdT, std::__detail::_StateIdT, bool) [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:251:24, inlined from 'void std::__detail::_Compiler<_TraitsT>::_M_disjunction() [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_compiler.tcc:103:18: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:405:42: warning: '*(std::function<bool(char)>*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::function<bool(char)>::_M_invoker' may be used uninitialized [-Wmaybe-uninitialized] 405 | : _Function_base(), _M_invoker(__x._M_invoker) | ~~~~^~~~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h: In member function 'void std::__detail::_Compiler<_TraitsT>::_M_disjunction() [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:246:17: note: '__tmp' declared here 246 | _StateT __tmp(_S_opcode_alternative); | ^~~~~ In member function 'bool std::_Function_base::_M_empty() const', inlined from 'std::function<_Res(_ArgTypes ...)>::operator bool() const [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:574:25, inlined from 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:407:6, inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_alt(std::__detail::_StateIdT, std::__detail::_StateIdT, bool) [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:251:24, inlined from 'void std::__detail::_Compiler<_TraitsT>::_M_disjunction() [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_compiler.tcc:103:18: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:247:37: warning: '*(const std::_Function_base*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::_Function_base::_M_manager' may be used uninitialized [-Wmaybe-uninitialized] 247 | bool _M_empty() const { return !_M_manager; } | ^~~~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h: In member function 'void std::__detail::_Compiler<_TraitsT>::_M_disjunction() [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:246:17: note: '__tmp' declared here 246 | _StateT __tmp(_S_opcode_alternative); | ^~~~~ In constructor 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]', inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_word_bound(bool) [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:309:24, inlined from 'bool std::__detail::_Compiler<_TraitsT>::_M_assertion() [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_compiler.tcc:153:16: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:405:42: warning: '*(std::function<bool(char)>*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::function<bool(char)>::_M_invoker' may be used uninitialized [-Wmaybe-uninitialized] 405 | : _Function_base(), _M_invoker(__x._M_invoker) | ~~~~^~~~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h: In member function 'bool std::__detail::_Compiler<_TraitsT>::_M_assertion() [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:307:17: note: '__tmp' declared here 307 | _StateT __tmp(_S_opcode_word_boundary); | ^~~~~ In member function 'bool std::_Function_base::_M_empty() const', inlined from 'std::function<_Res(_ArgTypes ...)>::operator bool() const [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:574:25, inlined from 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:407:6, inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_word_bound(bool) [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:309:24, inlined from 'bool std::__detail::_Compiler<_TraitsT>::_M_assertion() [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_compiler.tcc:153:16: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:247:37: warning: '*(const std::_Function_base*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::_Function_base::_M_manager' may be used uninitialized [-Wmaybe-uninitialized] 247 | bool _M_empty() const { return !_M_manager; } | ^~~~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h: In member function 'bool std::__detail::_Compiler<_TraitsT>::_M_assertion() [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:307:17: note: '__tmp' declared here 307 | _StateT __tmp(_S_opcode_word_boundary); | ^~~~~ In constructor 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]', inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_lookahead(std::__detail::_StateIdT, bool) [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:318:24, inlined from 'bool std::__detail::_Compiler<_TraitsT>::_M_assertion() [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_compiler.tcc:164:8: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:405:42: warning: '*(std::function<bool(char)>*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::function<bool(char)>::_M_invoker' may be used uninitialized [-Wmaybe-uninitialized] 405 | : _Function_base(), _M_invoker(__x._M_invoker) | ~~~~^~~~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h: In member function 'bool std::__detail::_Compiler<_TraitsT>::_M_assertion() [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:315:17: note: '__tmp' declared here 315 | _StateT __tmp(_S_opcode_subexpr_lookahead); | ^~~~~ In member function 'bool std::_Function_base::_M_empty() const', inlined from 'std::function<_Res(_ArgTypes ...)>::operator bool() const [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:574:25, inlined from 'std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:407:6, inlined from 'std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:149:4, inlined from 'std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_lookahead(std::__detail::_StateIdT, bool) [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:318:24, inlined from 'bool std::__detail::_Compiler<_TraitsT>::_M_assertion() [with _TraitsT = std::__cxx11::regex_traits<char>]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_compiler.tcc:164:8: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:247:37: warning: '*(const std::_Function_base*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::_Function_base::_M_manager' may be used uninitialized [-Wmaybe-uninitialized] 247 | bool _M_empty() const { return !_M_manager; } | ^~~~~~~~~~ /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h: In member function 'bool std::__detail::_Compiler<_TraitsT>::_M_assertion() [with _TraitsT = std::__cxx11::regex_traits<char>]': /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/regex_automaton.h:315:17: note: '__tmp' declared here 315 | _StateT __tmp(_S_opcode_subexpr_lookahead); | ^~~~~ -------------------- The same problem happens with Fedora 36 / gcc 12.1.1 and doesn't happen with 11.3. Not sure if it's a problem with g++, ASAN or libstdc++.