Re:Why Does Calloc Exist?
by bornfreddy on Sunday November 13, 2022 @09:19AM
(#33583297)
From my (admittedly very limited, and very dated) knowledge of x86 asm, I remember that multiplication sets some flags if there was an overflow. Is there no way to multiply in C so that such an overflow was detected? Or do some CPU architectures not support such flags? It seems inefficient (to me) to do this check before each multiplication.
[ Parent
| on HN ]
Re:Why Does Calloc Exist?
by SAI_Peregrinus on Sunday November 13, 2022 @10:59AM
(#33584209)
The C abstract machine does not have such flags. C therefore does not have any support for checking them (from code, the compiler can add checks if the target supports them but doesn't have to).