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

    <tr>
        <th>Summary</th>
        <td>
            Type trait assertions give the wrong result if used inside a containing struct
        </td>
    </tr>

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

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

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

<pre>
    Here is a tiny program that shows `std::is_default_constructible_v` is happy with a struct that contains a member initializer:

```c++
#include <type_traits>

struct Foo {
  int a = 0;
};

static_assert(std::is_default_constructible_v<Foo>);
```

This [compiles fine](https://godbolt.org/z/6rx68Yx1b) with `-std=c++17`. It also [works fine](https://godbolt.org/z/Es3GKTvfa) if we embed the struct inside of another one:

```c++
#include <type_traits>

struct Bar {
  struct Baz {
    int a = 0;
  };
};

static_assert(std::is_default_constructible_v<Bar::Baz>);
```

However if we add another type trait use inside of the parent struct, then *both* type trait assertions [fail](https://godbolt.org/z/7E4j9fPc4):

```c++
#include <type_traits>

struct Bar {
  struct Baz {
    int a = 0;
  };

  static_assert(std::is_default_constructible_v<Baz>);
};

static_assert(std::is_default_constructible_v<Bar::Baz>);
```

```
<source>:8:3: error: static assertion failed due to requirement 'std::is_default_constructible_v<Bar::Baz>'
  static_assert(std::is_default_constructible_v<Baz>);
  ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:11:1: error: static assertion failed due to requirement 'std::is_default_constructible_v<Bar::Baz>'
static_assert(std::is_default_constructible_v<Bar::Baz>);
^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

This seems wrong—`Baz` is already a complete type at the point that the assertion inside `Bar` is made, right?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVk1z6jYU_TWXzZ1khOQPWHgBIfR1uukim64Y2brGSmWLSjI8suhv78g2gb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