Код: Выделить всё
#include
int main()
{
static const std::regex rgx{"some string"};
}
Код: Выделить всё
g++ -O3 -fsanitize=address -Wall test.cpp
Код: Выделить всё
-fsanitize=addressКод: Выделить всё
In file included from /usr/include/c++/14/regex:50,
from test.cpp:1:
In constructor ‘std::function::function(std::function&&) [with _Res = bool; _ArgTypes = {char}]’,
inlined from ‘std::__detail::_State::_State(std::__detail::_State&&) [with _Char_type = char]’ at /usr/include/c++/14/bits/regex_automaton.h:149:4,
inlined from ‘std::__detail::_State::_State(std::__detail::_State&&) [with _Char_type = char]’ at /usr/include/c++/14/bits/regex_automaton.h:146:7,
inlined from ‘std::__detail::_StateIdT std::__detail::_NFA::_M_insert_subexpr_end() [with _TraitsT = std::__cxx11::regex_traits]’ at /usr/include/c++/14/bits/regex_automaton.h:290:24:
/usr/include/c++/14/bits/std_function.h:405:42: warning: ‘*(std::function*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State::.std::__detail::_State_base::)).std::function::_M_invoker’ may be used uninitialized [-Wmaybe-uninitialized]
405 | : _Function_base(), _M_invoker(__x._M_invoker)
| ~~~~^~~~~~~~~~
In file included from /usr/include/c++/14/regex:65:
/usr/include/c++/14/bits/regex_automaton.h: In member function ‘std::__detail::_StateIdT std::__detail::_NFA::_M_insert_subexpr_end() [with _TraitsT = std::__cxx11::regex_traits]’:
/usr/include/c++/14/bits/regex_automaton.h:287:17: note: ‘__tmp’ declared here
287 | _StateT __tmp(_S_opcode_subexpr_end);
| ^~~~~
Платформа — Fedora 41
Код: Выделить всё
$ g++ --version
g++ (GCC) 14.2.1 20240912 (Red Hat 14.2.1-3)
Что может вызвать эти предупреждения компилятора?
Подробнее здесь: https://stackoverflow.com/questions/792 ... d-warnings
Мобильная версия