5 ms·
What parts of it can't just be compiled as C++ code? (unless it has to do with the subtle difference in implicit lifetime object rules) IMO it's much easier to
by TuxSH 1y ago
What parts of it can't just be compiled as C++ code? (unless it has to do with the subtle difference in implicit lifetime object rules)
IMO it's much easier to write resleaks/double-frees with refcounted objects in C than it is in C++
- 1718627440 1y agoVLAs, named structure assignment, sane treatment of the void type, having different "lifetimes" for object (the C understanding of object) existence and initialization, having different namespaces for composed types and variables, a local error handling convention, leading to better error messages, robuster behaviour and a feeling for completeness, a lot of examples of the article and here in the thread, and most importantly no magic.
- TuxSH 1y ago> named structure assignment Is a thing since C++20 > sane treatment of the void type If you're talking about conversion rules, explicit cast from void* to T* makes more sense than implicit since it is a downcast. > VLAs IMO these are a mistake (and C++ templates remove a lot of the need for it). They give a false sense of security and invite stack boundary overrun as many people forget to check bounds on these. I found and reported an unauthenticated RCE DoS (crash) in a distributed DB due to VLAs; worse, one cannot always assume the minimum stack size on a system. > a local error handling convention Exceptions are problematic in their implementation and how they are (mis)used, but they are supposed to be orthogonal to normal control flow handling, and are not supposed to replace it. They are more-or-less recoverable panics
- 1718627440 1y ago> If you're talking about conversion rules, explicit cast from void* to T* makes more sense than implicit since it is a downcast. Yes, but you also need to specify the type in C. ((void *)p)->foo only works in New B not in C. > IMO these are a mistake Forgetting to check bounds does always result in these problems in C, this is not specific to VLAs. I find them useful. > Exceptions are problematic in their implementation Ok, but that means to me having these in the language is only a downside.