https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109242
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org Status|NEW |ASSIGNED --- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Peter Kasting from comment #2) > struct S { > int& i() const; > }; > > void foo() { > std::optional<S>().transform(&S::i); The U type is a reference here, which isn't allowed. This shows the bug: struct A { }; const A f(int); std::optional<int> o; A&& p = *o.transform(f);