[vlc-commits] [Git][videolan/vlc][master] vlc_list: use static_cast for std::nullptr_t conversion

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Feb 16 09:33:18 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
63dce4de by Alexandre Janniaux at 2024-02-16T09:05:53+00:00
vlc_list: use static_cast for std::nullptr_t conversion

Current code can lead to the following error:

    invalid cast from type 'std::nullptr_t' to type 'const volatile info_t*'

Following documentation[^1] from cppreference.com:

    9) The null pointer value of any pointer type can be converted to any
       other pointer type, resulting in the null pointer value of that type.
       Note that the null pointer constant nullptr or any other value of
       type std::nullptr_t cannot be converted to a pointer with
       reinterpret_cast: implicit conversion or static_cast should be used
       for this purpose.

[^1]: https://en.cppreference.com/w/cpp/language/reinterpret_cast

Fix #28526

- - - - -


1 changed file:

- include/vlc_list.hpp


Changes:

=====================================
include/vlc_list.hpp
=====================================
@@ -128,7 +128,7 @@ protected:
 
     constexpr std::ptrdiff_t offset() const {
         return reinterpret_cast<std::ptrdiff_t>(
-            &(reinterpret_cast<NodeType const volatile*>(NULL)->*_node_ptr)
+            &(static_cast<NodeType const volatile*>(NULL)->*_node_ptr)
         );
     }
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/63dce4de32c1a01d1cb3af81d351a9ae4fea0786

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/63dce4de32c1a01d1cb3af81d351a9ae4fea0786
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list