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

    <tr>
        <th>Summary</th>
        <td>
            __builtin_launder complains about type completeness
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            c++17,
            clang:frontend,
            diverges-from:gcc,
            diverges-from:msvc,
            diverges-from:edg
      </td>
    </tr>

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

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

<pre>
    `std::launder` does not require that the type pointed to is complete. See https://wg21.link/ptr.launder.

Clang refuses to compile the following:
```cpp
#include <new>
struct A;
A *h(A *p) { return std::launder(p); }
```
which becomes (with multiple C++ standard libraries):
```cpp
struct A;
A *h(A *p) { return __builtin_launder(p); }
```

Online compiler link: https://godbolt.org/z/8KG98zaxW

### SOURCE (`<stdin>`):
```cpp
struct A;
A *h(A *p) { return __builtin_launder(p); }
```

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

### ACTUAL COMPILER OUTPUT:
```
<stdin>:2:21: error: incomplete type 'A' where a complete type is required
    2 | A *h(A *p) { return __builtin_launder(p); }
      |                     ^
<stdin>:1:8: note: forward declaration of 'A'
    1 | struct A;
      |        ^
1 error generated.
```

### EXPECTED COMPILER OUTPUT:
(clean compile)

### COMPILER VERSION INFO (`clang++ -v`):
```
clang version 20.0.0git (https://github.com/llvm/llvm-project.git dd42651295d0e1566b34104b007ad19865c57fcc)
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/13
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/14
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/14
Candidate multilib: .;@m64
Selected multilib: .;@m64
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.ll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