<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/58206>58206</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Compilation errors with c++2b (clang++-14)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
AnFunctionArray
</td>
</tr>
</table>
<pre>
From this question:
[SO](https://stackoverflow.com/questions/73978544/unique-pointer-with-incomplete-type-c2b)
[APFloat.h DoubleAPFloat implementation](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/ADT/APFloat.h#L608)
**Simple example:**
```
#include <memory>
#include <llvm/ADT/APFloat.h>
```
```
clang++ -std=c++2b -I /usr/lib/llvm-14/include ../bugl.cpp
In file included from ../bugl.cpp:1:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/memory:76:
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unique_ptr.h:130:18: error: invalid application of 'sizeof' to an incomplete type 'llvm::APFloat'
static_assert(sizeof(_Tp)>0,
^~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unique_ptr.h:669:4: note: in instantiation of function template specialization 'std::default_delete<llvm::APFloat[]>::operator()<llvm::APFloat>' requested here
get_deleter()(__ptr);
^
/usr/lib/llvm-14/include/llvm/ADT/APFloat.h:601:7: note: in instantiation of member function 'std::unique_ptr<llvm::APFloat[]>::~unique_ptr' requested here
class DoubleAPFloat final : public APFloatBase {
^
/usr/lib/llvm-14/include/llvm/ADT/APFloat.h:625:13: note: in implicit destructor for 'llvm::detail::DoubleAPFloat' first required here
this->~DoubleAPFloat();
^
/usr/lib/llvm-14/include/llvm/ADT/APFloat.h:38:7: note: forward declaration of 'llvm::APFloat'
class APFloat;
^
In file included from ../bugl.cpp:1:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/memory:76:
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unique_ptr.h:720:9: error: subscript of pointer to incomplete type 'llvm::APFloat'
return get()[__i];
^~~~~
/usr/lib/llvm-14/include/llvm/ADT/APFloat.h:633:38: note: in instantiation of member function 'std::unique_ptr<llvm::APFloat[]>::operator[]' requested here
APFloat &getFirst() { return Floats[0]; }
^
/usr/lib/llvm-14/include/llvm/ADT/APFloat.h:38:7: note: forward declaration of 'llvm::APFloat'
class APFloat;
^
2 errors generated.
```
**In case it's a language bug (and not library one):**
```
#include <memory>
class dummy;
std::unique_ptr<dummy[]> test;
int main() {
const dummy &refdum = test[0];
}
class dummy {
};
```
Compiles with c++20 but not with c++2b:
```
clang++ -std=c++2b ../bugl.cpp
In file included from ../bugl.cpp:1:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/memory:76:
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unique_ptr.h:130:18: error: invalid application of 'sizeof' to an incomplete type 'dummy'
static_assert(sizeof(_Tp)>0,
^~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unique_ptr.h:669:4: note: in instantiation of function template specialization 'std::default_delete<dummy[]>::operator()<dummy>' requested here
get_deleter()(__ptr);
^
../bugl.cpp:4:26: note: in instantiation of member function 'std::unique_ptr<dummy[]>::~unique_ptr' requested here
std::unique_ptr<dummy[]> test;
^
../bugl.cpp:2:7: note: forward declaration of 'dummy'
class dummy;
^
In file included from ../bugl.cpp:1:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/memory:76:
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unique_ptr.h:720:9: error: subscript of pointer to incomplete type 'dummy'
return get()[__i];
^~~~~
../bugl.cpp:7:31: note: in instantiation of member function 'std::unique_ptr<dummy[]>::operator[]' requested here
const dummy &refdum = test[0];
^
../bugl.cpp:2:7: note: forward declaration of 'dummy'
class dummy;
^
2 errors generated.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWN1vozgQ_2vIi0VETMLHAw9J00grnXQn7b5HBkziPQKcbdrN_vU3YyAUlnTbbru9kxq5jmOP7ZnffLpxmZ6jnSxPRB-FIv_UXGlRFpa7tpyt5XT9avP5T2u1tWhw1LpSuEx30JRmyd_lHZdZXt7Pk_IEc90ZCsa-G_rBarmEYV0IWLGrUhSaS_te6KMtCthS5VxzW58rbic0tmg4unn91y4vmZ4fybas45y3v4nAnSdeaGY4nuDuAHfUcctWnt91X3Yly6880fAzzku4cndiouhpgK28Tnk_sd5-wb5jxKLuH54TjFml2D4btgj_xvDbsGLaQ0LPaVu7z20vJJZ7c-KnUp4t93Zq8Qo7F-LRwVOTSc6Kg0U30IitdGq526T5SWNifyKoKSVRdBF3cC2WPShkPkfY6kM-T6qKNId-KkgmQOqWJiUZWtSAEpBYXKxqmv5ydWyUYbY3XBwS4HH3LfD23tLORVF_sw9FDVML2hGOul6FrXQdcYfv2vd6I_8dF8dCq4sb7CstUXHrhetgH0BHuJSlxIEo7lguUsKqKheJMW9SZoCPr8R3XmYwILokrCC9AxF0ICQxNgKSuevWQGCuEZNcPgp9JtkzpbiE9aA7Nth_qdCq3VvHojfjXcOPtbq1_Efbe2PreSDJeomIFqXmDbLQQPpCiwusWV0kZqw5QMkASlXxRIAGvjc0iDs6CmKa8ozVud6nHEHvXHIA92qDsQh80syWFZdMg16piRdTG4AUFCq5CZzgDEcu-Rj7A-_u7E4CZaGk5tDNmByVM4T_ijtfj3GAn4Me6_8MP_ComMsexodw9Rp5AlRgMw_or0AC8UupUSbIRMFygvxVMC0S0i5smAKX8AfovA4ydGV8dwzNCf1VaJIC17JOQO0kg7-BV6ZcM5E344EYKHEmpNJGbiEnLAFztI14-bejrcG0HbySvG4wNgQQ657JFCQFhciHIep6_GlUd7H6abV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