[clang] [Clang][Sema] placement new initializes typedef array with correct size (PR #83124)
Pranav Kant via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 23 14:22:25 PDT 2024
pranavk wrote:
```
In file included from /usr/local/foo/home/prka/wip/unique/test.cpp:1:
In file included from /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/memory:78:
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unique_ptr.h:1085:14: error: no matching conversion for functional-style cast from 'unsigned short *' to 'unique_ptr<unsigned short[][256]>'
1085 | { return unique_ptr<_Tp>(new remove_extent_t<_Tp>[__num]()); }
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/foo/home/prka/wip/unique/test.cpp:10:47: note: in instantiation of function template specialization 'std::make_unique<unsigned short[][256]>' requested here
10 | const std::unique_ptr<Node[]> nodes_ = std::make_unique<Node[]>(max_nodes_);
| ^
/usr/local/foo/home/prka/wip/unique/test.cpp:15:38: note: in instantiation of member function 'Base<256>::Base' requested here
15 | explicit Child(size_t max_bytes) : Base<256>(max_bytes) {
| ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unique_ptr.h:648:7: note: candidate constructor not viable: no known conversion from 'unsigned short *' to 'unique_ptr<unsigned short[][256]>' for 1st argument
648 | unique_ptr(unique_ptr&&) = default;
| ^ ~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unique_ptr.h:652:12: note: candidate constructor template not viable: no known conversion from 'unsigned short *' to 'nullptr_t' (aka 'std::nullptr_t') for 1st argument
652 | constexpr unique_ptr(nullptr_t) noexcept
| ^ ~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unique_ptr.h:796:7: note: candidate constructor not viable: no known conversion from 'unsigned short *' to 'const unique_ptr<unsigned short[][256]>' for 1st argument
796 | unique_ptr(const unique_ptr&) = delete;
| ^ ~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unique_ptr.h:603:2: note: candidate template ignored: requirement '__and_<std::__or_<std::__or_<std::is_same<unsigned short *, unsigned short (*)[256]>, std::is_same<unsigned short *, std::nullptr_t>>, std::__and_<std::is_pointer<unsigned short *>, std::is_same<unsigned short (*)[256], unsigned short (*)[256]>, std::is_convertible<unsigned short (*)[], unsigned short (*)[][256]>>>>::value' was not satisfied [with _Up = unsigned short *, _Vp = std::default_delete<unsigned short[][256]>, $2 = _DeleterConstraint<default_delete<unsigned short[][256]>>]
603 | unique_ptr(_Up __p) noexcept
| ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unique_ptr.h:662:2: note: candidate template ignored: could not match 'unique_ptr<_Up, _Ep>' against 'unsigned short *'
662 | unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept
```
We get error messages like above with this commit. This compiles fine without this commit or with gcc.
https://github.com/llvm/llvm-project/pull/83124
More information about the cfe-commits
mailing list