https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119407
Bug ID: 119407 Summary: Missed optimization for identical branches Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: fiesh at zefix dot tv Target Milestone: --- Consider this (somewhat nonsensical) code snippet -----8<----- #include <vector> std::vector<int> f(int const i) { if (i == 42) { return {}; } std::vector<int> v; return v; } std::vector<int> g(int const i) { std::vector<int> v; if (i == 42) { return v; } return v; } -----8<----- See https://godbolt.org/z/8WaY6orcE for its generated assembly. There are two exactly identical branches, yet they are both emitted.