Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Time is not guaranteed to be signed. W Hat you have there is undefined behaviour.


It's probably more likely to be implementation-defined behaviour (as with the signedness of 'char') rather than undefined behaviour.

The third alternative being unspecified behaviour - see comp.lang.c FAQ 11.33 for more info: https://c-faq.com/ansi/undef.html


Surely it's unspecified behavior, at worst.


The signedness of time_t is unspecified. If you rely on it being signed and overflowing so it goes back to before January 01, 1970, well, that's living on the edge....


Only if your code is intended to be portable. If you know the signedness of time_t in your implementation, there's no harm in assuming it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: