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

    <tr>
        <th>Summary</th>
        <td>
            diagnostic divergence between -std=c++20 and -std=c++17 when referencing member of std::vector of incomplete type
        </td>
    </tr>

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

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

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

<pre>
    In the following code example, I perform a value initialization of a std::vector of incomplete type.

```c++
#include <vector>

struct B;

struct A {
    std::vector<B> _;
};

A a{};  // <--here

struct B {};
```

https://godbolt.org/z/ab5Erqc1n

This runs afoul of the second half of https://eel.is/c++draft/vector#overview-4. "T shall be complete before any member of the resulting specialization of vector is referenced." I do not know if this is ill-formed or undefined behavior.

Staring in `clang-15`, this is diagnosed as invalid, but only with `-std=c++20`. Thisimplies to me that this diagnostic is probably incidental. For consistency it would be helpful if this diagnostic could be emitted for all standard versions, as a Quality of Implementation improvement.

As a reference I have added https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108669 to normalize this diagnostic across clang and gcc.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVE2P4jgT_jXmUiIKdiDNIQf6A6mPr965jxy7ktSuY7O2E5b-9atKM3TDjrRSBFLF9biej5ROiXqP2Ijts9i-rvSUhxAbZ7XDlPSqDfbSvHvIA0IXnAtn8j2YYBHwbz2eHAr5Au9wwtiFOIKGWbsJgTxl0o4-dKbgIXSgIWUr1EGow4wmh8hF8iYwSEbIlxMWonwV5eH6uys_HyPkMz-fVanIGzdZBKFePpGEevvemHKcTIZnoZ5_Uz6AqK91AHgcSqiXZ6He4OdXc_36AHQAzRBLHUDIo5BHHma9HjDi7yaB2_kHat8PDzmfEs-yAPbBtsHlIsReyOOHkEfdbt_iX2bjvzf9GChBnHwC3YXJsaZsVUITvIVBu45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