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

--- Comment #27 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>:

https://gcc.gnu.org/g:59bfdd5f467292a368d0d628084a4b65d1bb06bb

commit r13-6830-g59bfdd5f467292a368d0d628084a4b65d1bb06bb
Author: Marek Polacek <pola...@redhat.com>
Date:   Fri Mar 17 14:36:10 2023 -0400

    c++: further -Wdangling-reference refinement [PR107532]

    Based on <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107532#c24>,
    it seems like we should treat *any* class with a reference member
    as a reference wrapper.  To suppress the warning in

      int i = 42;
      auto const& v = std::get<0>(std::tuple<int&>(i));

    we have to look into base classes as well.  For std::tuple, this means
    that we have to check the _Head_base subobject, which is a non-direct
    base class of std::tuple.  So I've employed a DFS walk.

            PR c++/107532

    gcc/cp/ChangeLog:

            * call.cc (class_has_reference_member_p): New.
            (class_has_reference_member_p_r): New.
            (reference_like_class_p): Don't look for a specific constructor.
            Use a DFS walk with class_has_reference_member_p_r.

    gcc/testsuite/ChangeLog:

            * g++.dg/warn/Wdangling-reference11.C: New test.
            * g++.dg/warn/Wdangling-reference12.C: New test.

Reply via email to