-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use (arith) 1 << ... when getting the sign bit.
This prevents an overflow reported by @hexcoder- in #56 lang/cem/cpp.ansi/LLlex.c used a plain 1 << ... and caused an overflow on machines where sizeof(int) < sizeof(long). Using 1L << ... would work for now but might fail later if arith became long long. C doesn't specify whether negative integers use 2's complement or some other format. Therefore, (arith) 1 << ... has an undefined value. It should still work because the value is some integer where the sign bit is set and all other bits are clear. (unsigned arith) 1 << ... would also get the sign bit, but casting it from unsigned back to signed would make the same undefined value. (arith) -1 << ... would assume 2's complement.
- Loading branch information
Showing
5 changed files
with
6 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters