News for hackers. Stuff that matters.
Re:A Quiz About Integers in C by antirez on Monday June 04, 2012 @02:50AM (#4062944)
in theory yes, but often there are cases where you can't avoid mixing signed and unsigned stuff for example. Think about write() and read() syscalls that will return a signed type, but are often used in a context where buffer lengths are expressed in unsigned types.
Re:A Quiz About Integers in C by JulianMorrison on Monday June 04, 2012 @09:16AM (#4063823)
Then you probably want to mark it with an explicit function named something like "int32_to_uint32()" which you have defined (and debugged) in one place that performs the appropriate conversion with sanity checks.

Basically, IMO, C's implicit conversions are a flaw in the spec. A more sensible language would require every conversion (aside from those involving un-dimensioned constant data) to be spelled out explicitly. Since you can't make C sensible, the next best thing is to scrupulously isolate the stupid parts.