public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/104959] New: nested lambda capture pack by ref will load from nullptr
@ 2022-03-16 16:06 andij.cr at gmail dot com
2022-12-14 5:37 ` [Bug tree-optimization/104959] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: andij.cr at gmail dot com @ 2022-03-16 16:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104959
Bug ID: 104959
Summary: nested lambda capture pack by ref will load from
nullptr
Product: gcc
Version: 10.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: andij.cr at gmail dot com
Target Milestone: ---
testcase:
#include <cassert>
template <auto>
auto line = []<typename... Ts>(Ts &&...args) {
if constexpr (sizeof...(Ts) != 0) {
([&] { assert(&args != nullptr); }(), ...);
}
};
int main() { line<10>(false); }
compiling and executing this with
g++ 10.3 -std=c++20 -O1 -fsanitize=undefined
will trigger the assertion.
this code is a reduction of a more complex code, where the bug caused a crash.
compiling with -O0 or with GCC 11 will not trigger the assertion.
each template, lambda, if constexpr (sizeof...) seems to be necessary
to trigger the bug
the assert needs to be here to trigger the load of args
using a different method (e.g. using args in an expression)
will also trigger -Wuninitialized
compiler explorer link:
https://gcc.godbolt.org/z/W7EMTP4W8
note that in the assembly __assert_fail is called directly
this seems similar to
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68177
and
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97938
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug tree-optimization/104959] nested lambda capture pack by ref will load from nullptr
2022-03-16 16:06 [Bug tree-optimization/104959] New: nested lambda capture pack by ref will load from nullptr andij.cr at gmail dot com
@ 2022-12-14 5:37 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-14 5:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104959
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|UNCONFIRMED |RESOLVED
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=97938
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed in GCC 10.4.0 by the patch for PR 97938.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-14 5:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-16 16:06 [Bug tree-optimization/104959] New: nested lambda capture pack by ref will load from nullptr andij.cr at gmail dot com
2022-12-14 5:37 ` [Bug tree-optimization/104959] " pinskia at gcc dot gnu.org
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).