diff --git a/stl/inc/xlocale b/stl/inc/xlocale index 874f94288da..2a96cec62ac 100644 --- a/stl/inc/xlocale +++ b/stl/inc/xlocale @@ -380,12 +380,12 @@ public: return nullptr; // no entry in current locale } - _NODISCARD bool operator==(const locale& _Loc) const { // compare locales for equality - return _Ptr == _Loc._Ptr || (name().compare("*") != 0 && name().compare(_Loc.name()) == 0); + _NODISCARD bool operator==(const locale& _Loc) const noexcept /* strengthened */ { // compare locales for equality + return _Ptr == _Loc._Ptr || (_CSTD strcmp(_C_str(), "*") != 0 && _CSTD strcmp(_C_str(), _Loc._C_str()) == 0); } #if !_HAS_CXX20 - _NODISCARD bool operator!=(const locale& _Right) const { + _NODISCARD bool operator!=(const locale& _Right) const noexcept /* strengthened */ { return !(*this == _Right); } #endif // !_HAS_CXX20 diff --git a/tests/std/tests/Dev09_056375_locale_cleanup/test.cpp b/tests/std/tests/Dev09_056375_locale_cleanup/test.cpp index ce23d39c16c..11a5f969769 100644 --- a/tests/std/tests/Dev09_056375_locale_cleanup/test.cpp +++ b/tests/std/tests/Dev09_056375_locale_cleanup/test.cpp @@ -11,6 +11,9 @@ using namespace std; #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) +STATIC_ASSERT(noexcept(locale{} == locale{})); +STATIC_ASSERT(noexcept(locale{} != locale{})); + void test_dll() { puts("Calling dll"); #ifdef _M_CEE