[PATCH] libstdc++: fix compile error when converting std::weak_ptr<T[]>
Giuseppe D'Angelo
giuseppe.dangelo@kdab.com
Tue Dec 10 00:58:06 GMT 2024
Hello,
The attached patch fixes a compile error when converting a weak_ptr of
array type to a compatible type, for instance:
std::weak_ptr<int [42]> wptr;
std::weak_ptr<int []> wptr2 = wptr; // ERROR
https://gcc.godbolt.org/z/EWYb73Mvf
The reason seems to be a typo: the inner __weak_ptr class has a lock()
implementation which doesn't work with arrays because it accidentally
uses `element_type` instead of `_Tp`. That lock() (and *not*
std::weak_ptr::lock(), which is instead fine) is called by the
converting constructors of __weak_ptr and that causes the compile error.
I'm not sure if this has been already reported somewhere.
Tested on x86-64 Linux.
Thanks,
--
Giuseppe D'Angelo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-libstdc-fix-compile-error-when-converting-std-weak_p.patch
Type: text/x-patch
Size: 7120 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20241210/e1b9e278/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4244 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20241210/e1b9e278/attachment-0001.p7s>
More information about the Libstdc++
mailing list