5 ms·
Yes there is. RAII is not a full replacement for GC and you will shoot yourself in the foot if you treat it as such. The design of C++ also includes many unpatc
by dminik 8mo ago
Yes there is. RAII is not a full replacement for GC and you will shoot yourself in the foot if you treat it as such. The design of C++ also includes many unpatchable holes in the standard library which WILL cause errors and UB.
- Moldoteck 8mo agoSo how exactly would this shooting in the foot look like compared to say java
- dminik 8mo agoToo many to list, but for some examples: You take a reference to a vector element, which you later accidentally invalidate by pushing to the same vector. You move out of a unique_ptr, but then you accidentally use it again. You create a cycle with shared_ptr causing a memory leak. If you std::sort a list of floats with NaNs (among other things) you can stomp over memory. The sort function requires some very specific ordering otherwise you get UB.
- player1234 8mo ago[dead]
- Moldoteck 8mo agothx! For some reason I thought Java too has invalidation problem