public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111410] New: Bogus Wdangling-reference warning with ranges pipe expression in for loop
@ 2023-09-14  1:09 hewillk at gmail dot com
  2024-01-18 22:10 ` [Bug c++/111410] " mpolacek at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: hewillk at gmail dot com @ 2023-09-14  1:09 UTC (permalink / raw)
  To: gcc-bugs

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

            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 <iostream>
#include <vector>
#include <ranges>

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:

<source>: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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-01-20 20:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-14  1:09 [Bug c++/111410] New: Bogus Wdangling-reference warning with ranges pipe expression in for loop hewillk at gmail dot com
2024-01-18 22:10 ` [Bug c++/111410] " mpolacek at gcc dot gnu.org
2024-01-18 22:53 ` mpolacek at gcc dot gnu.org
2024-01-20 20:42 ` cvs-commit at gcc dot gnu.org
2024-01-20 20:43 ` mpolacek 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).