[Bug c++/102482] Winit-list-lifetime false positive for temporaries with std::initializer_list

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Oct 7 13:55:58 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102482

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:9b239d05ffd5a17ede44abd55bc6622c6e279868

commit r12-4228-g9b239d05ffd5a17ede44abd55bc6622c6e279868
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Sep 29 21:19:49 2021 +0100

    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.


More information about the Gcc-bugs mailing list