https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86465
--- Comment #15 from Geoff <geoff3jones at googlemail dot com> --- This appears to still be an issue in gcc 11.2 minimal reproduced example using std::optional https://godbolt.org/z/ebbMe3Wva std::optional<bool> empty_optional(int x){ return {}; } std::optional<bool> empty_optional_or_true(int x){ if(x > 0){ return std::make_optional(true); } return {}; // <- second here } int main(){ empty_optional_or_true }