public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "andrey.vihrov at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/105562] New: [12 Regression] std::function<bool(char)>::_M_invoker may be used uninitialized in std:regex move with -fno-strict-aliasing Date: Wed, 11 May 2022 10:48:09 +0000 [thread overview] Message-ID: <bug-105562-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105562 Bug ID: 105562 Summary: [12 Regression] std::function<bool(char)>::_M_invoker may be used uninitialized in std:regex move with -fno-strict-aliasing Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: andrey.vihrov at gmail dot com Target Milestone: --- Consider the following sample: #include <regex> int main() { std::regex a("."); std::regex b(std::move(a)); } Since GCC 12.1, compiling this code with "g++ -Wall -O1 -fno-strict-aliasing x.cpp" gives In file included from /usr/include/c++/12.1.0/regex:48, from x.cpp:1: 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 /usr/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 /usr/include/c++/12.1.0/bits/regex_automaton.h:290:24: /usr/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 /usr/include/c++/12.1.0/regex:63: /usr/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>]': /usr/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 /usr/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 /usr/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 /usr/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 /usr/include/c++/12.1.0/bits/regex_automaton.h:290:24: /usr/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; } | ^~~~~~~~~~ /usr/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>]': /usr/include/c++/12.1.0/bits/regex_automaton.h:287:17: note: '__tmp' declared here 287 | _StateT __tmp(_S_opcode_subexpr_end); | ^~~~~ There are no warnings with -fstrict-aliasing. Related resources: * https://gcc.gnu.org/pipermail/gcc/2021-July/236851.html * https://gcc.gnu.org/g:c22bcfd2f7dc9bb5ad394720f4a612327dc898ba
next reply other threads:[~2022-05-11 10:48 UTC|newest] Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-05-11 10:48 andrey.vihrov at gmail dot com [this message] 2022-05-11 10:55 ` [Bug libstdc++/105562] [12/13 Regression] std::function<bool(char)>::_M_invoker may be used uninitialized in std::regex move with -fno-strict-aliasing since r12-6216-g5a431b60d1f22199 marxin at gcc dot gnu.org 2022-05-11 11:05 ` rguenth at gcc dot gnu.org 2022-05-11 11:32 ` andrey.vihrov at gmail dot com 2022-05-11 11:54 ` redi at gcc dot gnu.org 2022-05-11 12:44 ` [Bug libstdc++/105562] std::function<bool(char)>::_M_invoker may be used uninitialized in std::regex move with -fno-strict-aliasing redi at gcc dot gnu.org 2022-05-11 12:56 ` redi at gcc dot gnu.org 2022-05-11 12:57 ` redi at gcc dot gnu.org 2022-05-11 12:59 ` redi at gcc dot gnu.org 2022-05-12 9:27 ` jakub at gcc dot gnu.org 2022-05-12 9:35 ` jakub at gcc dot gnu.org 2022-05-12 9:54 ` rguenth at gcc dot gnu.org 2022-05-12 9:57 ` rguenth at gcc dot gnu.org 2022-05-12 10:07 ` rguenth at gcc dot gnu.org 2022-05-12 11:27 ` cvs-commit at gcc dot gnu.org 2022-05-12 11:28 ` [Bug libstdc++/105562] [12 Regression] " rguenth at gcc dot gnu.org 2022-05-19 12:47 ` cvs-commit at gcc dot gnu.org 2022-05-19 12:50 ` rguenth at gcc dot gnu.org 2022-10-22 0:50 ` pinskia at gcc dot gnu.org 2023-05-26 21:40 ` urisimchoni at gmail dot com 2023-09-12 12:04 ` jakub1miernik at gmail dot com 2023-12-06 10:03 ` romain.geissler at amadeus dot com 2023-12-06 10:26 ` rguenth at gcc dot gnu.org 2023-12-06 10:35 ` romain.geissler at amadeus dot com 2023-12-06 10:43 ` rguenther at suse dot de 2023-12-06 10:50 ` jakub at gcc dot gnu.org 2023-12-06 11:13 ` romain.geissler at amadeus dot com 2023-12-06 11:16 ` sjames at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-105562-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).