[clang] Reapply "[Clang][CWG1815] Support lifetime extension of temporary created by aggregate initialization using a default member initializer" (PR #92527)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 6 03:02:32 PDT 2024


alexfh wrote:

> Here's the reproducer:
> 
> ```c++
> struct a {
>   virtual int *b();
> };
> template <class c> struct d : a {
>   int *b() { new c; }
> };
> int *e(a *);
> struct f {
>   char *g;
> };
> struct h {};
> struct i {
>   i(const f &);
>   i(h);
> };
> struct l {
>   i j = i({.g = ""});
> };
> int *k = e(new d<l>);
> struct n : l {};
> int *m = e(new d<n>);
> ```

A bit clearer repro: https://gcc.godbolt.org/z/r9EdcoW8G

The new clang behavior seems wrong to me.

https://github.com/llvm/llvm-project/pull/92527


More information about the cfe-commits mailing list