Wandbox
SettingsLog
SettingsLog
Language
GitHubLogin
Ran/Viewed Log

Author

anonymous

over 2 years ago

Language

C

Compiler

gcc 13.2.0

Options
Warnings
C11(GNU)
no pedantic

Author

anonymous

over 2 years ago

$ gcc prog.c -Wall -Wextra -std=gnu11
prog.c: In function 'main':
prog.c:10:43: warning: left shift of negative value [-Wshift-negative-value]
   10 |     dbg("The rest value", -1 - ((-1 >> 3) << 3));
      |                                           ^~
prog.c:3:46: note: in definition of macro 'dbg'
    3 | #define dbg(m, x) printf(m ": " #x" = %d\n", x)
      |                                              ^
When the diff is positive: +1 >> 3 = 0
The rest value: +1 - ((+1 >> 3) << 3) = 1
When the diff is negative: -1 >> 3 = -1
The rest value: -1 - ((-1 >> 3) << 3) = 7
With div instad of >>: +1 / (1 << 3) = 0
The rest value: +1 - ((+1 / (1 << 3)) << 3) = 1
With div instad of >>: -1 / (1 << 3) = 0
The rest value: -1 - ((-1 / (1 << 3)) << 3) = -1
Exit Code:
0