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

    <tr>
        <th>Summary</th>
        <td>
            std::optional as a member variable of a parent class, cause std::is_constructible_v to fail.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          Marc-Pierre-Barbier
      </td>
    </tr>
</table>

<pre>
    Hello,

while trying to migrate one of my apps to clang i discovered the following issue.

i have a class A contained within class B.  class A has a std::optional<B> as a member value.
class B contains a double that i want initialise to 0. the simples option is to use =0 or {} instead of writing a constructor. but when i do that combined with the std::optional<B> any usage of std::optional<B>::emplace(not limited to the member variable) will fail to compile. This is because B is no longer constructible according to `is_constructible_v`  but it still according to `is_default_constructible_v`. The weirdest part ? commenting out std::optional<B> will allow the code to compile alternatively defining a default contructor in B that do the initialisation of the double will also fix it.

Tested with the following code using clang 17(using gcc10)
```C++
#include <optional>

class A {
public:
    class B {
 public:
        //removing the {} will fix the compilation
 double example{};
    };
    //alternatively commenting this will fix the compilation
    std::optional<B> transmission{};
};

int main(int argc, char ** argv) {
        using test = A::B;
        static_assert(std::is_constructible<test>::value == true);
        static_assert(std::is_default_constructible_v<A::B>);
        static_assert(std::is_constructible_v<test>);


        std::optional<test> a;
        //emplace use std::is_constructible_v
        a.emplace();
        return 0;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVU2P4jgQ_TXmUmoUnAaSQw5AD9rLSnuY-6iSFKRWjo3sCkz_-5Wd8DXdvbOLopA4ro_36lUZQ-CjJarUcquWbzMcpHO--hN98_IXk_f0skVfM_lZ7dr36g8yxim9U9mbyjbj_dKxIRD_zvYI4qDno0chcJbAHaB_BzydQvzSGLRHYGg5NO5MnlqQjuDgjHGXaM0hDDR_dM7Q4ZkAo20IsIHGWUG21MK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