Missing optimization: if constexpr(false) prevents NRVO #50297
Open
Description
| Bugzilla Link | 50953 |
| Version | trunk |
| OS | Linux |
| CC | @apolukhin,@zygoloid |
Extended Description
Consider the following code:
struct A {
A() = default;
A(A&&);
};
template
A foo() {
A a;
if constexpr (B) {
return A();
}
return a;
}
A test() {
return foo();
}
In the above example NRVO for a is applied by many compilers, but not clang.
Godbolt playground: https://godbolt.org/z/P8G3zj5GE
Activity