Skip to content

default integer value limits to 128 bits with __int128 extensions, fix for [GH #38] - #265

Open
mohitmishra786 wants to merge 1 commit into
edgcpp:mainfrom
mohitmishra786:gh-38-int128-max-integer-value
Open

mohitmishra786 wants to merge 1 commit into
edgcpp:mainfrom
mohitmishra786:gh-38-int128-max-integer-value

Conversation

@mohitmishra786

Copy link
Copy Markdown
Contributor

Fixes #38.

With a 128-bit host integer representation, MAX_INTEGER_VALUE, MIN_INTEGER_VALUE and MAX_UNSIGNED_INTEGER_VALUE stayed at their 64-bit values, so the overflow checks in const_ints.c rejected valid __int128 constant arithmetic ((__int128)1 << 100 times 4 gave "expression must have a constant value"). The macOS CMake configurations use this representation by default.

  • targ_def.h: when INT128_EXTENSIONS_ALLOWED, the default limits are those of __int128_t / __uint128_t.
  • defines_linux.h and the Linux base.cmakedef no longer hard-code the 64-bit limits, so changing the integer value types to the 128-bit types also changes the limits. The limits are only used when INTEGER_VALUE_REPR_IS_A_HOST_INTEGER is TRUE, and the default Linux builds use the array representation, so their behavior is unchanged.

Testing (Docker, linux-gcc-debug):

  • A build with INTEGER_VALUE_REPR_IS_A_HOST_INTEGER=1 and the __int128 types reproduced the error before the change. After it, valid __int128 arithmetic is accepted and real overflows (MAX + 1, MIN / -1, MAX * 2, MIN * 2) are still diagnosed, the same as the default build.
  • changes/ and all tests using __int128: no differences from the expectations in edg_x86_64 and edg_x86_64_cp.
  • linux-i686-gcc-debug builds.

@mohitmishra786

Copy link
Copy Markdown
Contributor Author

@wchilders-nvidia @nv-cmeerw @daveedvdv could you please review this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GNATS 27353] Set MAX_INTEGER_VALUE/MAX_UNSIGNED_INTEGER_VALUE properly for 128-bit integers

1 participant