Zoltan Borok-Nagy has posted comments on this change. ( 
http://gerrit.cloudera.org:8080/16174 )

Change subject: IMPALA-9925 cast(pow(2, 31) as int) return 2147483647 on aarch64
......................................................................


Patch Set 6:

Thanks for the answer.

INT_MAX is definitely 2147483647 for 32 bit integers, but that doesn't mean it 
is the right value for pow(2, 31). On the other hand, there is no right value 
for pow(2, 31) among 32 bit integers. pow(2, 31) causes an int32 overflow which 
is undefined behavior, so anything can happen. See https://godbolt.org/z/PxhY3z 
It simply assigns INT_MAX to 'stati' even for pow(2, 55).

So it seems like on one platform pow(2, 31) is -2147483648 which is transformed 
to the correct value after abs() or multiplication (because they cast it to 
BIGINT). Other platforms seem to take a different approach and assign INT_MAX 
in case of overflow. Since overflows are undefined behaviors maybe we can 
accept both answers.


--
To view, visit http://gerrit.cloudera.org:8080/16174
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I58ab52acebb9bcddbf298efa886fd30ce35f68bf
Gerrit-Change-Number: 16174
Gerrit-PatchSet: 6
Gerrit-Owner: Anonymous Coward <[email protected]>
Gerrit-Reviewer: Anonymous Coward <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>
Gerrit-Reviewer: Tim Armstrong <[email protected]>
Gerrit-Reviewer: Zoltan Borok-Nagy <[email protected]>
Gerrit-Comment-Date: Mon, 10 Aug 2020 13:27:39 +0000
Gerrit-HasComments: No

Reply via email to