From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3ED5F3858CDA; Thu, 14 Sep 2023 01:10:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3ED5F3858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694653801; bh=Wh9DGjz9hjPrluzjUPge8ILboWyIDh6MJEnOPAMhuVs=; h=From:To:Subject:Date:From; b=m92IcLgwt+NpSCErShMYV/eKPOGhvD5XTWlYP9bM8DUT+Z7+KCIJtYZxJisSDWaot dbGzTr0m4dsVW+TJ+eBue+URu4Ze+BBnDIrM/9+Nd4RZqBGovm8Xw/sLBeaSMZ92t/ OxWnP/b8ookwA6NAuRkCrVu3I/a4S0Sz1QYHOcGE= From: "hewillk at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111410] New: Bogus Wdangling-reference warning with ranges pipe expression in for loop Date: Thu, 14 Sep 2023 01:09:58 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hewillk at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111410 Bug ID: 111410 Summary: Bogus Wdangling-reference warning with ranges pipe expression in for loop Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hewillk at gmail dot com Target Milestone: --- #include #include #include int main() { std::vector v{1, 2, 3, 4, 5}; for (auto i : std::span{v} | std::views::take(1)) std::cout << i << '\n'; } GCC-trunk reports the following warning when the -Wall flag is used: :8:51: warning: possibly dangling reference to a temporary [-Wdangling-reference] 8 | for ( auto i : std::span{v} | std::views::take(1)) | ^ https://godbolt.org/z/5jhnTTej9=