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

--- Comment #5 from Valentin Tolmer <valentin at tolmer dot fr> ---
Note that there's the same issue with calling a class initializer with multiple
arguments (but not a function or a constructor).

Refactored example to remove ASAN:
```
#include <iostream>
struct s {
    char c_;
    s(char c) : c_(c) {std::cout << "constructed s " << c << "\n";}
    ~s(){std::cout << "destructed s " << c_ << "\n";}
};

struct a {
    s b{'b'};
    s c{'c'};
    //a(s d, s e) : b(d), c(e){}
    //a() = default;
};

a fn(){
    return a{
        s{'x'},
        ({ return a{}; s{'y'}; })
    };
}

int main(){
    fn();
}
```
prints:
constructed s x
constructed s b
constructed s c
destructed s c
destructed s b

The temporary s x is never destructed. Uncommenting the constructors removes
the temporary altogether. This one reproduces as far back as it will compile
(so, gcc 6.1).

Reply via email to