Skip to content

Commit b06526b

Browse files
committed
Add comment on INT64_MIN edge case
1 parent 23337a1 commit b06526b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

source/slang/slang-parser.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -6678,6 +6678,13 @@ static BaseType _determineNonSuffixedIntegerLiteralType(
66786678

66796679
if (isDecimalBase)
66806680
{
6681+
// There is an edge case here where 9223372036854775808 or INT64_MAX + 1
6682+
// brings us here, but the complete literal is -9223372036854775808 or INT64_MIN and is valid.
6683+
// Unfortunately because the lexer handles the negative(-) part of the literal separately
6684+
// it is impossible to know whether the literal has a negative sign or not.
6685+
// We emit the warning and initially process it as a uint64 anyways, and the negative sign
6686+
// will be properly parsed and the value will still be properly stored as a negative INT64_MIN.
6687+
66816688
// Decimal integer is too large to be represented as signed.
66826689
// Output warning that it is represented as unsigned instead.
66836690
sink->diagnose(

0 commit comments

Comments
 (0)