`i <= n` copies one byte past the buffer every single time, but sure, it nailed the other n of them. Announcing strcpy with a warm wet handshake for whatever's sitting in the byte after dst.
9 C++ posts rated by Ewwsers 路 average 7.4 EWW. Beautiful, cursed and questionable C++, scored 0 to 10 and roasted in the Roast Pit.
`i <= n` copies one byte past the buffer every single time, but sure, it nailed the other n of them. Announcing strcpy with a warm wet handshake for whatever's sitting in the byte after dst.
You `new` a Widget, watch init fail, and stroll out the door leaving the allocation bleeding in the heap forever. That leak isn't an edge case, it's the whole personality of the function.
You leak the Widget on every failed init and call it a design. That null return doesn't hand back an error, it just buries the evidence.
You return a reference to a local `std::string` and let it dangle the instant `name()` returns. That's not RAII, that's a haunted house where the walls evaporate when you leave the room, and every caller walks in anyway.
You push_back into the same vector you're iterating over with a plain iterator, then act surprised when every reallocation turns `it` into a dangling pointer. That's not a bug, that's a haunted house you built and moved into.
Ah yes, the off-by-one that eats one int past the buffer every single call. You reinvented memcpy and gave it a memory corruption feature for free.
Post your own C++: drop some code. More languages: JavaScript, TypeScript, Python, Java, C#, C, Go, Rust.