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

    <tr>
        <th>Summary</th>
        <td>
            Clang allows, in constexpr, trivial union copy constructor to read uninitialized subobjects of active member
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            c++20
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          hubert-reinterpretcast
      </td>
    </tr>
</table>

<pre>
    Lvalue-to-rvalue conversion of objects having indeterminate value is not allowed during evaluation of a core constant expression (see N4919 subclause 7.7 [expr.const] bullet 5.11). Clang allows such lvalue-to-rvalue conversion during the constant evaluation of trivial union copy constructors.

In the case below, the `y` member of `u` has indeterminate value (as does the corresponding bytes of the object representation) when the initialization of `v` is performed. ICC correctly diagnoses the issue.

Compiler Explorer link: https://godbolt.org/z/6174nqhbE

### SOURCE (`<stdin>`):
```
struct A {
  int x, y;
  constexpr A() {}
};

union U { A x; };

constexpr int f() {
  U u = { A() };
  u.x.x = 42;
  U v = u;
  return v.x.x;
}

extern constexpr int x = f();
```

### COMPILER INVOCATION:
```
clang++ -xc++ -fsyntax-only -std=c++2a -
```

### ACTUAL OUTPUT:
(Clean compile)

### EXPECTED OUTPUT:
(Error that `x` is not initialized by a constant expression)

### COMPILER VERSION INFO (`clang++ -v`):
```
clang version 16.0.0 (https://github.com/llvm/llvm-project.git 629a29cacc09def1821def8f4d5455b4be5ac9b1)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/wandbox/clang-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Selected multilib: .;@m64
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVttu4zgPf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