3 ms·
Where there is UB in the standard it means that a C compiler is free to define the behavior. So of course, somebody could write a C implementation which does th
by uecker 8mo ago
Where there is UB in the standard it means that a C compiler is free to define the behavior. So of course, somebody could write a C implementation which does this. See also Fil-C for a perfectly memory safe version of C. So the first sentence makes no sense.
But also note that there is an ongoing effort to remove UB from the standard. We have eliminated already about 30% of UB in the core language for the upcoming version C2Y.
- Panzerschrek 8mo agoC is designed in such a way, that designing a safe compiler without big performance penalties isn't possible. How much Fil-C is slower compared to something like GCC? 2 to 5 times slower?
- uecker 8mo agoThis is only relevant for specific types of UB, and even there it is not entirely clear. One of the main challenges is ABI compatibility and separate compilation. Both are not necessarily part of the "design of C". If you are willing to give this up, a lot can be done. Annotations are another possibility to get full memory safety without performance cost.