Skip to content

[FIX] Fix the function isctype failed in arm64-big-endian #73200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 7, 2023

Conversation

W-50243
Copy link
Contributor

@W-50243 W-50243 commented Nov 23, 2023

'isctype' failes in arm64-big-endian, this is because the __regex_word involved in the type mask operation is not changed based on big-endian or little-endian, while the character mask that participates in the budget changes accordingly.

@W-50243 W-50243 requested a review from a team as a code owner November 23, 2023 03:07
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Nov 23, 2023
@llvmbot
Copy link
Member

llvmbot commented Nov 23, 2023

@llvm/pr-subscribers-libcxx

Author: None (W-50243)

Changes

'isctype' failes in arm64-big-endian, this is because the __regex_word involved in the type mask operation is not changed based on big-endian or little-endian, while the character mask that participates in the budget changes accordingly.


Full diff: https://github.com/llvm/llvm-project/pull/73200.diff

1 Files Affected:

  • (modified) libcxx/include/__locale (+1-1)
diff --git a/libcxx/include/__locale b/libcxx/include/__locale
index b1502dd71edadf6..ef56135f2f1d45e 100644
--- a/libcxx/include/__locale
+++ b/libcxx/include/__locale
@@ -384,7 +384,7 @@ public:
     static const mask punct  = _ISpunct;
     static const mask xdigit = _ISxdigit;
     static const mask blank  = _ISblank;
-#if defined(__mips__)
+#if defined(__mips__) || (BYTE_ORDER == BIG_ENDIAN)
     static const mask __regex_word = static_cast<mask>(_ISbit(15));
 #else
     static const mask __regex_word = 0x80;

Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you point out what test fails without this patch and on what platform? This patch is probably fine but I don't understand it without additional context, so I can't accept it as-is.

@ldionne ldionne merged commit 6ea3344 into llvm:main Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants