Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

wow, can you elaborate how adding a string field can break some assumptions?




Not the OP, but note that adding a std::string to a POD type makes it non-POD. If you were doing something like using malloc() to make the struct (not recommended in C++!), then suddenly your std::string is uninitialized, and touching that object will be instant UB. Uninitialized primitives are benign unless read, but uninitialized objects are extremely dangerous.

That's not what was happening in this example though. It would be UB even if it was a POD.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: