https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78058
Bug ID: 78058 Summary: Complex initialization of nested std::optional does not work Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: akrzemi1 at gmail dot com Target Milestone: --- The following program fails to compile: ``` #include <cassert> #include <optional> using std::optional; using std::nullopt; using std::in_place; int main() { optional<optional<optional<int>>> o (in_place, in_place, nullopt); assert (o); assert (*o); assert (!**o); } ``` Overload resolution cannot find the right constructor. I expect this to compile, the meaning is described with the assertions. The middle optional is initialized with two arguments {in_place, nullopt}, which means that the innermost optional is initialized with nullptr. The same program compiles with the reference implementation: https://github.com/akrzemi1/Optional