Re: [PATCH] c++: -Wdangling-reference and system headers

2022-10-28 Thread Jason Merrill via Gcc-patches
On 10/27/22 11:39, Marek Polacek wrote: I got this testcase: auto f() -> std::optional; for (char c : f().value()) { } which has a dangling reference: std::optional::value returns a reference to the contained value, but here it's the f() temporary. We warn, which is great, but only with -

[PATCH] c++: -Wdangling-reference and system headers

2022-10-27 Thread Marek Polacek via Gcc-patches
I got this testcase: auto f() -> std::optional; for (char c : f().value()) { } which has a dangling reference: std::optional::value returns a reference to the contained value, but here it's the f() temporary. We warn, which is great, but only with -Wsystem-headers, because the function comes