Re: [PATCH] c++: Extend -Wdangling-reference for std::minmax

2022-11-10 Thread Marek Polacek via Gcc-patches
On Thu, Nov 10, 2022 at 08:07:25AM -1000, Jason Merrill wrote: > On 11/9/22 15:56, Marek Polacek wrote: > > This patch extends -Wdangling-reference to also warn for > > > >auto v = std::minmax(1, 2); > > > > which dangles because this overload of std::minmax returns > > a std::pair where the

Re: [PATCH] c++: Extend -Wdangling-reference for std::minmax

2022-11-10 Thread Jason Merrill via Gcc-patches
On 11/9/22 15:56, Marek Polacek wrote: This patch extends -Wdangling-reference to also warn for auto v = std::minmax(1, 2); which dangles because this overload of std::minmax returns a std::pair where the two references are bound to the temporaries created for the arguments of std::minmax.

[PATCH] c++: Extend -Wdangling-reference for std::minmax

2022-11-09 Thread Marek Polacek via Gcc-patches
This patch extends -Wdangling-reference to also warn for auto v = std::minmax(1, 2); which dangles because this overload of std::minmax returns a std::pair where the two references are bound to the temporaries created for the arguments of std::minmax. This is a common footgun, also described