Skip to content

[libc] Fix definition of UINT_MAX in limits.h #95279

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 1 commit into from
Jun 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions libc/include/llvm-libc-macros/limits-macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
#endif // INT_MAX

#ifndef UINT_MAX
#define UINT_MAX (~0U)
#define UINT_MAX (INT_MAX * 2U + 1U)
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we explicitly cast ((unsigned) INT_MAX)?

Copy link
Contributor Author

@jhuber6 jhuber6 Jun 12, 2024

Choose a reason for hiding this comment

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

Should be handled by the 2U part, otherwise it would fail in the myriad templates we use in limits.h I believe. This is how Clang's implementation does it at least.

#endif // UINT_MAX

#ifndef LONG_MAX
Expand All @@ -160,7 +160,7 @@
#endif // LONG_MAX

#ifndef ULONG_MAX
#define ULONG_MAX (~0UL)
#define ULONG_MAX (LONG_MAX * 2UL + 1UL)
#endif // ULONG_MAX

#ifndef LLONG_MAX
Expand All @@ -172,7 +172,7 @@
#endif // LLONG_MAX

#ifndef ULLONG_MAX
#define ULLONG_MAX (~0ULL)
#define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
#endif // ULLONG_MAX

// *_MIN macros
Expand Down
Loading