[move] Why not use std::addressof when available for boost::move_detail::addressof rather than undocumented __builtin_addressof
Hi all, I noticed that a change was made to boost::move_detail::addressof implementation to address some potential GCC compiler alignment warnings: https://github.com/boostorg/move/commit/7637429b6c361321cf0512014949f86be32a... The new implementation uses GCC's __builtin_addressof (which remains purposefully undocumented, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96634 ), or uses a clever series of casts. And it doesn't take advantage of the potential existence of std::addressof. Is there any reason why not use std::addressof when it is available (since C++11)? (Aside: I ran across this because I have an unusual situation, where the new clever casts are an issue (but the previous clever implementation was alright, but presumably caused strict-alignment warnings), and using __builtin_addressof is an issue too. In all cases, std::addressof will work fine for me and seems like it would be preferable for all, when available.) -Travis
El 06/11/2025 a las 4:18, Travis Pouarz via Boost escribió:
Hi all,
I noticed that a change was made to boost::move_detail::addressof implementation to address some potential GCC compiler alignment warnings: https://github.com/boostorg/move/commit/7637429b6c361321cf0512014949f86be32a...
The new implementation uses GCC's __builtin_addressof (which remains purposefully undocumented, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96634 ), or uses a clever series of casts. And it doesn't take advantage of the potential existence of std::addressof.
Is there any reason why not use std::addressof when it is available (since C++11)?
(Aside: I ran across this because I have an unusual situation, where the new clever casts are an issue (but the previous clever implementation was alright, but presumably caused strict-alignment warnings), and using __builtin_addressof is an issue too. In all cases, std::addressof will work fine for me and seems like it would be preferable for all, when available.)
Boost.Move is precisely there to support C++03 ;-) In any case, including <memory> in some compilers (like VS2022) requires 1,3MB of preprocessed source code, which seems overkill for such a tiny component. Could you please fill an issue in boostorg/move with your problem? Best, Ion
participants (2)
-
Ion Gaztañaga -
travisp@mailhaven.com