Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 0 additions & 3 deletions cmake/macro-conf/support/platform/linux/base.cmakedef
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ LONG_LONG_ALLOWED=1
INTEGER_VALUE_REPR_IS_A_HOST_INTEGER=0
TYPE_FOR_AN_INTEGER_VALUE=unsigned long long
TYPE_FOR_A_SIGNED_INTEGER_VALUE=long long
MAX_INTEGER_VALUE=9223372036854775807LL
MIN_INTEGER_VALUE=(-MAX_INTEGER_VALUE-1)
MAX_UNSIGNED_INTEGER_VALUE=18446744073709551615ULL
FP_LONG_DOUBLE_IS_80BIT_EXTENDED=1
LINKER_CAN_DISCARD_DUPLICATE_DEFINITIONS=1

Expand Down
18 changes: 18 additions & 0 deletions src/Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
Version 7.1

10/17/26 [GH #38]
Integer value limits for a 128-bit host integer representation

When target integers are represented by a 128-bit host integer (for example,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of referring to "macOS CMake configuraton", this should say which macro setting is responsible (I think it is INTEGER_VALUE_REPR_IS_A_HOST_INTEGER?)

in the macOS CMake configurations), MAX_INTEGER_VALUE, MIN_INTEGER_VALUE, and
MAX_UNSIGNED_INTEGER_VALUE still defaulted to 64-bit limits. As a result,
constant arithmetic on __int128 values that did not fit in 64 bits could be
wrongly diagnosed as overflowing. For example:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This needs something like --gnu_version 150200 to make __int128 available (so say For example, with --gnu_version 150200:)


constexpr __int128 s = (__int128)1 << 100;
static_assert(s * 4 == ((__int128)1 << 102), ""); // Previously an error.

This is now fixed: When __int128 extensions are allowed, the default limits

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That seems mostly redundant?

are those of the 128-bit types. The Linux configurations no longer hard-code
the 64-bit limits, so they also get the 128-bit limits when the integer value
types are changed to the 128-bit types.


10/16/26 [GH #229]
Improper handling of "if constexpr" substatements

Expand Down
3 changes: 0 additions & 3 deletions src/defines_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,6 @@ Linux.
#ifndef TYPE_FOR_A_SIGNED_INTEGER_VALUE
#define TYPE_FOR_A_SIGNED_INTEGER_VALUE long long
#endif /* TYPE_FOR_A_SIGNED_INTEGER_VALUE */
#define MAX_INTEGER_VALUE 9223372036854775807LL
#define MIN_INTEGER_VALUE (-MAX_INTEGER_VALUE-1)
#define MAX_UNSIGNED_INTEGER_VALUE 18446744073709551615ULL

#if defined(__aarch64__) || defined(__riscv)
/* 64-bit ARM and RISC-V use a 128-bit long double representation. */
Expand Down
12 changes: 12 additions & 0 deletions src/targ_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,9 @@ typedef TYPE_FOR_A_SIGNED_INTEGER_VALUE a_signed_integer_value;

/* Minimum and maximum values that can be represented in an_integer_value. */
#ifndef MAX_INTEGER_VALUE
#if INT128_EXTENSIONS_ALLOWED
#define MAX_INTEGER_VALUE ((__int128_t)(~(__uint128_t)0 >> 1))
#else /* !INT128_EXTENSIONS_ALLOWED */
#if LONG_LONG_ALLOWED
#ifdef LLONG_MAX
#define MAX_INTEGER_VALUE LLONG_MAX
Expand All @@ -1545,8 +1548,12 @@ typedef TYPE_FOR_A_SIGNED_INTEGER_VALUE a_signed_integer_value;
#else /* !LONG_LONG_ALLOWED */
#define MAX_INTEGER_VALUE LONG_MAX
#endif /* LONG_LONG_ALLOWED */
#endif /* INT128_EXTENSIONS_ALLOWED */
#endif /* ifndef MAX_INTEGER_VALUE */
#ifndef MIN_INTEGER_VALUE
#if INT128_EXTENSIONS_ALLOWED
#define MIN_INTEGER_VALUE (-MAX_INTEGER_VALUE-1)
#else /* !INT128_EXTENSIONS_ALLOWED */
#if LONG_LONG_ALLOWED
#if defined(LLONG_MIN) && LLONG_MIN < LLONG_MAX /*lint !e30*/
/* The preceding condition detects an incorrect definition of LLONG_MIN
Expand All @@ -1558,8 +1565,12 @@ typedef TYPE_FOR_A_SIGNED_INTEGER_VALUE a_signed_integer_value;
#else /* !LONG_LONG_ALLOWED */
#define MIN_INTEGER_VALUE LONG_MIN
#endif /* LONG_LONG_ALLOWED */
#endif /* INT128_EXTENSIONS_ALLOWED */
#endif /* ifndef MIN_INTEGER_VALUE */
#ifndef MAX_UNSIGNED_INTEGER_VALUE
#if INT128_EXTENSIONS_ALLOWED
#define MAX_UNSIGNED_INTEGER_VALUE (~(__uint128_t)0)
#else /* !INT128_EXTENSIONS_ALLOWED */
#if LONG_LONG_ALLOWED
#ifdef ULLONG_MAX
#define MAX_UNSIGNED_INTEGER_VALUE ULLONG_MAX
Expand All @@ -1569,6 +1580,7 @@ typedef TYPE_FOR_A_SIGNED_INTEGER_VALUE a_signed_integer_value;
#else /* !LONG_LONG_ALLOWED */
#define MAX_UNSIGNED_INTEGER_VALUE ULONG_MAX
#endif /* LONG_LONG_ALLOWED */
#endif /* INT128_EXTENSIONS_ALLOWED */
#endif /* ifndef MAX_UNSIGNED_INTEGER_VALUE */
#ifndef BITS_IN_AN_INTEGER_VALUE
#define BITS_IN_AN_INTEGER_VALUE (sizeof(an_integer_value) * CHAR_BIT)
Expand Down
Loading