[Bug c++/96004] New: Copy elision with conditional
antoshkka at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Jun 30 14:24:49 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96004
Bug ID: 96004
Summary: Copy elision with conditional
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: antoshkka at gmail dot com
Target Milestone: ---
Consider the example:
struct Struct {
Struct() = default;
Struct(Struct&&);
};
Struct question10(bool b) {
if (b) {
Struct s{};
return s;
} else {
return {};
}
}
It is possible to elide move constructor call as the lifetimes of object `s`
and `return {}` do not intersect.
(some other compilers already do copy elision in that place
https://godbolt.org/z/wdpLkT )
More information about the Gcc-bugs
mailing list