2 ms·
The change I proposed is not disruptive in any way. As for the billion dollar mistake, a null pointer reference results in a seg fault. But the array decay res
by WalterBright 3y ago
The change I proposed is not disruptive in any way.
As for the billion dollar mistake, a null pointer reference results in a seg fault. But the array decay results in buffer overflows, the #1 problem in shipped C code, and the buffer overflows result in memory corruption. Memory corruption is much, much, much worse than a seg fault. For example, buffer overflows are exploitable by malware. Seg faults are not.
Hence, the array decay is the worst mistake.
- WalterBright 3y agoI am baffled by the lack of interest in incorporating the proposal into C. Instead, C23 gets Unicode normalized identifiers, a complex and pointless feature that is easily achieved by other means, if one really really wants it.
- turndown 3y agoYour post is great and provides an elegant solution to the syntactic case for parameters, but it also lacks almost all detail on how this would work in practice. Say I’m writing the `void food(char a[..])` function. What are the semantics of this fat pointer type, exactly? How do I access the size? What is the ABI around this like? How is the size set on a fat pointer? It just requires so much extra stuff to get it into proposal shape.
- WalterBright 3y agoThis is all thoroughly implemented in D, so I know it works. It's probably D's most well-liked feature. > semantics Accessing a[i] means i gets checked against the array length, and it's a fatal error if it doesn't. > ABI Same as struct {size_t length; void* ptr;} > size sizeof(a) > length __length(a) or something like that