| Issue |
58206
|
| Summary |
Compilation errors with c++2b (clang++-14)
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
AnFunctionArray
|
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.
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs