]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Do not warn about lifetime of std::initializer_list<T>& [PR102482]
authorJonathan Wakely <jwakely@redhat.com>
Wed, 29 Sep 2021 20:19:49 +0000 (21:19 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 7 Oct 2021 13:55:35 +0000 (14:55 +0100)
commit9b239d05ffd5a17ede44abd55bc6622c6e279868
tree9d80b0afbf62a56f873f4e731669d7fef3747f87
parent44b61586d8640b79e78cfdb6a555200ccee8df77
c++: Do not warn about lifetime of std::initializer_list<T>& [PR102482]

An initializer-list constructor taking a non-const lvalue cannot be
called with a temporary, so the array's lifetime probably doesn't end
with the full expression. -Winit-list-lifetime should not warn for that
case.

PR c++/102482

gcc/cp/ChangeLog:

* init.c (maybe_warn_list_ctor): Do not warn for a reference to
a non-const std::initializer_list.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Winit-list5.C: New test.
gcc/cp/init.c
gcc/testsuite/g++.dg/warn/Winit-list5.C [new file with mode: 0644]