in reply to Beautiful code I wrote ;-)
Doesn't C have an obligatory warning for this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Beautiful code I wrote ;-)
by massa (Hermit) on Jul 15, 2008 at 15:01 UTC | |
even with -Wall -pedantic, gcc does not complain. And there would be no reason to. 1 << a >> 1 is very much a well-formed C expresion, meaning "shift left the int with value '1' by 'a' bits; shift right the result by one bit".
[]s, HTH, Massa
| [reply] [d/l] [select] |
by ambrus (Abbot) on Jul 15, 2008 at 18:08 UTC | |
Gcc indeed doesn't seem to complain, however, there was a reason why I remembered there was a warning, and it's a different compiler. Borland C 3.1 has such a warning. Update: I recreated a variant of the screenshot I've linked to and made a text export. Non-ascii characters are wrong so the image I linked to is still better, but I copy the text version here in case you can't view the image and because it's not hosted on perlmonks.
| [reply] [d/l] |