Commit d0ff6b4c authored by jan.koester's avatar jan.koester
Browse files

string: no ambiguous += for string_view-convertible types; weak __atomic_*

std::string += x for a type with operator string_view() (cmake's
cmValue) matched both the dedicated overload and the generic
operator+=(const Str&) -- cmake stopped compiling.

The generic __atomic_load/store/exchange/compare_exchange are weak:
on powerpc compiler-rt's builtins, linked into libc, define them too.

Co-Authored-By: default avatarClaude Opus 5.5 <noreply@anthropic.com>
parent 265df85d
Loading
Loading
Loading
Loading
+3 −1
Changes for include/cxx/string: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -1516,7 +1516,9 @@ public:
    /* Same real SFINAE-guard requirement as append(const Str&) above
     * (see its comment) -- an unconstrained version here would have
     * the exact same real raw-array-binding bug. */
    template<class Str>
    /* not for types with operator string_view(): their own operator+=
     * above takes them (both matched cmake's cmValue: ambiguous) */
    template<class Str, class = enable_if_t<!__string_detail::__sv_operator<Str>::value>>
    auto operator+=(const Str& s) -> decltype(append(s)) { return append(s); }

    bool starts_with(const char* s) const noexcept {
+4 −4
Changes for src/atomic.cpp: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -60,26 +60,26 @@ extern "C" {
#pragma redefine_extname __systempp_atomic_exchange __atomic_exchange
#pragma redefine_extname __systempp_atomic_compare_exchange __atomic_compare_exchange

__attribute__((visibility("default")))
__attribute__((visibility("default"), weak))
void __systempp_atomic_load(size_t size, void* src, void* dest, int) {
    atomic_guard g(src);
    memcpy(dest, src, size);
}

__attribute__((visibility("default")))
__attribute__((visibility("default"), weak))
void __systempp_atomic_store(size_t size, void* dest, void* src, int) {
    atomic_guard g(dest);
    memcpy(dest, src, size);
}

__attribute__((visibility("default")))
__attribute__((visibility("default"), weak))
void __systempp_atomic_exchange(size_t size, void* ptr, void* val, void* old, int) {
    atomic_guard g(ptr);
    memcpy(old, ptr, size);
    memcpy(ptr, val, size);
}

__attribute__((visibility("default")))
__attribute__((visibility("default"), weak))
bool __systempp_atomic_compare_exchange(size_t size, void* ptr, void* expected, void* desired, int, int) {
    atomic_guard g(ptr);
    if (memcmp(ptr, expected, size) == 0) {