4 ms·
Thanks, I didn't know all of this. At the beginning of the conversation I was quite sure about C's behavior. I guess liberal compilers don't help. C is a sim
by paskozdilar 5y ago
Thanks, I didn't know all of this. At the beginning of the conversation I was quite sure about C's behavior. I guess liberal compilers don't help.
C is a simple language, but it is hard to get it right sometimes.
- rssoconnor 5y agoIn C, multiplying two unsigned shorts together can lead to undefined behaviour.
- josephcsible 5y agoIn case it's not obvious how this can happen, it's because the promotion rules can turn them into signed ints, and if they're big enough the product can overflow that. For more details, see https://cryptoservices.github.io/fde/2018/11/30/undefined-behavior.html https://cryptoservices.github.io/fde/2018/11/30/undefined-be...