<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/61705>61705</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang++ fails to compile a call to emplace() on an std::optional<A::B>
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          olha5b
      </td>
    </tr>
</table>

<pre>
    This test program:

```
#include <optional>

int main(int, char *[])
{
    struct A
    {
        struct B
        {
 int c{};
        };

        std::optional<B> b1;
 };

    std::optional<A::B> b2;
    b2.emplace();

    return 0;
}
```

fails to compile with default clang on Ubuntu 22.10:

```
$ uname -a
Linux emu 5.19.0-23-generic #24-Ubuntu SMP PREEMPT_DYNAMIC Fri Oct 14 15:39:57 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

$ clang++ --version
Ubuntu clang version 15.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

$ clang++ -std=c++17 test.cxx -o test
test.cxx:16:8: error: no matching member function for call to 'emplace'
 b2.emplace();
 ~~~^~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/optional:914:2: note: candidate template ignored: requirement 'is_constructible_v<A::B>' was not satisfied [with _Args = <>]
        emplace(_Args&&... __args)
 ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/optional:926:2: note: candidate function template not viable: requires at least argument '__il', but no arguments were provided
 emplace(initializer_list<_Up> __il, _Args&&... __args)
        ^
1 error generated.
```

Hints:
- The compilation does not fail when the definition of `b1` is removed, or when the initialization of `c` is removed (`{}`}.
- I saw the bug at least also with clang 14.0.6 and 16.0.0 when self-compiled with gcc 12.1.0 on Debian 11, but a colleague reported success with a clang package of openSUSE. Not sure, maybe the bug depends on the compiler or configuration with which clang is compiled.
</pre>
<img width="1px" height="1px" alt="" src="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