News for hackers. Stuff that matters.
Re:Dangerous Embedded C Coding Standard Rules (2011) by angersock on Monday December 30, 2013 @04:06PM (#6986952)
Memory escapes me...is a shift guaranteed by the standard (and if so, which) to sign-extend or not sign-extend?
Re:Dangerous Embedded C Coding Standard Rules (2011) by kps on Monday December 30, 2013 @04:33PM (#6987115)
No, it isn't.

A right shift of a signed, negative value is implementation-defined (which means, something in particular happens, and the compiler or its documentation is supposed to tell you what).

A left shift of a signed value is undefined (which means, the compiler is allowed to launch the missiles, or fail to launch the missiles, whichever is worse for you) if a nonzero bit could conceivable get into the sign.

Re:Dangerous Embedded C Coding Standard Rules (2011) by kristoffer on Monday December 30, 2013 @04:31PM (#6987107)
A right shift of a signed integer is implementation defined.