3 ms·
> nobody wants C to backstab them with UB, but at the same time programmers want compilers to generate optimal code The value of compiler optimization isn't th
by MaxBarraclough 5y ago
> nobody wants C to backstab them with UB, but at the same time programmers want compilers to generate optimal code
The value of compiler optimization isn't the same thing as the value of having extensive undefined behaviour in a programming language.
Rust and Ada perform about the same as C, but lack C's many footguns.
> indexing `arr[i]` can't use 64-bit memory addressing modes
What do you mean here?
- remexre 5y agoTypically, the assembly instruction that would do the read in arr[i] can do something like: x = *(y + z); where y and z are both 64-bit integers. If I had int arr[1000]; initialize(&arr); int i = read_int(); int x = arr[i]; print(x); then to get x I'd need to do something like, tmp = i * 4; tmp1 = (uint64_t)tmp; x = *(arr + tmp1); Which, since i is signed, can't just be a cheap shift, and then needs to be upcasted to a uint64_t (which is cheap, at least).