[llvm-branch-commits] [libcxx] [NFC][libc++] Guard against operator& hijacking. (PR #128351)
Louis Dionne via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Feb 25 08:45:10 PST 2025
================
@@ -353,9 +354,9 @@ _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_
typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
if (std::__pad_and_output(
_Ip(__os),
- &__c,
- (__os.flags() & ios_base::adjustfield) == ios_base::left ? &__c + 1 : &__c,
- &__c + 1,
+ std::addressof(__c),
+ std::addressof(__c) + ((__os.flags() & ios_base::adjustfield) == ios_base::left),
----------------
ldionne wrote:
I'm not a big fan of using a `bool` as an `int` here. I'd even be OK with `addressof(c) + (bool-condition ? 1 : 0)`.
https://github.com/llvm/llvm-project/pull/128351
More information about the llvm-branch-commits
mailing list