On 10/01/2022 22:51, Martin Sebor via Gcc-patches wrote:
Last ping for this stage 1 feature before stage 3 ends:
https://gcc.gnu.org/pipermail/gcc-patches/2021-November/585819.html
This hits somewhat unexpectedly at (test case reduced from a hit in
LibreOffice)
$ cat test.cc
#include <initializer_list>
struct S1 {
S1(int);
~S1();
};
struct S2 { S2(std::initializer_list<S1>); };
S2 f1();
S2 f2(bool b) { return b ? f1() : S2{0}; }
$ g++ -Wdangling-pointer -c test.cc
test.cc: In function ‘S2 f2(bool)’:
test.cc:8:42: warning: dangling pointer to an unnamed temporary may be used
[-Wdangling-pointer=]
8 | S2 f2(bool b) { return b ? f1() : S2{0}; }
| ^
test.cc:8:39: note: unnamed temporary defined here
8 | S2 f2(bool b) { return b ? f1() : S2{0}; }
| ^
test.cc:8:42: warning: dangling pointer to an unnamed temporary may be used
[-Wdangling-pointer=]
8 | S2 f2(bool b) { return b ? f1() : S2{0}; }
| ^
test.cc:8:39: note: unnamed temporary defined here
8 | S2 f2(bool b) { return b ? f1() : S2{0}; }
| ^