4 ms·
> At least with C, if I try and treat something as a size_t it will try and behave like a size_t. It might not actually be the right type and cause problems tha
by lmm 7y ago
> At least with C, if I try and treat something as a size_t it will try and behave like a size_t. It might not actually be the right type and cause problems that way - but the behaviour is within the expected bounds.
Usually the C behaviour is undefined, at which point it can do absolutely anything. If it just gives you an arbitrary value and chugs along (as many C implementations will do), that's harder to understand and diagnose. If you run a big calculation in Javascript and it comes out as "true5", it's pretty clear what's gone wrong (and pretty easy to bisect the calculation to find where the mistake is). If you make the same code error in C you'll get an answer like 823491 and might not even realise that it's incorrect.
- saagarjha 7y ago> If you make the same code error in C you'll get an answer like 823491 and might not even realise that it's incorrect. Or, worse, your code will give you "true5", but only on Tuesdays at 2 AM when your server load is low, and you'll look at the code and wonder how it's possible something like this could ever happen…
- madmax96 7y agoThe C behavior in this case isn't undefined, unless you go out of your way to violate aliasing rules or something -- but that's a far reach from what parent was saying.