https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122172

--- Comment #25 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <[email protected]>:

https://gcc.gnu.org/g:385984f5554a90cd039bf8be1525a63d46ca9750

commit r16-4373-g385984f5554a90cd039bf8be1525a63d46ca9750
Author: Jonathan Wakely <[email protected]>
Date:   Mon Oct 6 15:51:28 2025 +0100

    libstdc++: Fix warnings from std::make_unsigned<_Atomic_word> [PR122172]

    GCC gives a -Wignored-attributes warning when a class template is
    instantiated with a type that has an aligned(n) attribute. Specifically,
    cris-elf uses 'typedef int __attribute_((__aligned(4))) _Atomic_word;'
    and so compiling libstdc++ headers gives:
    warning: ignoring attributes on template argument âintâ
[-Wignored-attributes]

    This commit reduces four occurrences of make_unsigned<_Atomic_word> into
    two, one in bits/shared_ptr_base.h and one in ext/atomicity.h, and uses
    diagnostic pragmas around the two remaining uses to avoid the warnings.
    Because the unsigned type might have lost the alignment of _Atomic_word
    that is needed for atomic ops (at least on cris-elf), the unsigned type
    should only be used for plain non-atomic arithmetic. To prevent misuse,
    it's defined as a private type in _Sp_counted_base, and is defined and
    then undefined as a macro in ext/atomicity.h, so that it's not usable
    after __exchange_and_add_single and __atomic_add_single have been
    defined.

    We also get a warning from instantiating __int_traits<_Atomic_word> in
    shared_ptr_base.h which can be avoided by calculating the maximum signed
    value from the maximum unsigned value.

    libstdc++-v3/ChangeLog:

            PR libstdc++/122172
            * include/bits/shared_ptr_base.h (_Sp_counted_base): Define
            _Unsigned_count_type for make_unsigned<_Atomic_word>.
            Replace __int_traits<_Atomic_word> with equivalent expression.
            * include/ext/atomicity.h (_GLIBCXX_UNSIGNED_ATOMIC_WORD):
            Define macro for unsigned type to use for arithmetic.
            (__exchange_and_add_single, __atomic_add_single): Use it.

    Reviewed-by: Hans-Peter Nilsson <[email protected]>

Reply via email to