-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shifts of non-integers and left shifts of negative integers are undef…
…ined 6.5.7 of C11: "Each of the operands shall have integer type." Paragraph 4: "If E1 has a signed type and nonnegative value, and E1 x 2^E2 is representable in the result type, then that is the resulting value; otherwise, the behavior is undefined."
- Loading branch information
1 parent
6bb3872
commit 1e3712c
Showing
3 changed files
with
44 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
int main() | ||
{ | ||
unsigned char x; | ||
unsigned r=x << ((sizeof(unsigned)-1)*8); | ||
r=x << ((sizeof(unsigned)-1)*8-1); | ||
r=(unsigned)x << ((sizeof(unsigned)-1)*8); | ||
|
||
int s=-1 << ((sizeof(int)-1)*8); | ||
s=-256 << ((sizeof(int)-1)*8); | ||
return 0; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CORE | ||
main.c | ||
--undefined-shift-check | ||
^SIGNAL=0$ | ||
^\[.*\] shift operand is negative in .*: FAILURE$ | ||
^\*\* 1 of 2 failed | ||
^VERIFICATION FAILED$ | ||
-- | ||
^warning: ignoring |
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