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

main takeaway of the article according to the author, quoting:

> In my humble opinion, here’s the key takeaway: just write your own fucking constructors! You see all that nonsense? Almost completely avoidable if you had just written your own fucking constructors. Don’t let the compiler figure it out for you. You’re the one in control here. Or is it that you think you’re being cute? You just added six instances of undefined behaviour to your company’s codebase, and now twenty Russian hackers are fighting to pwn your app first. Are you stupid? What’s the matter with you? What were you thinking? God.

The problem with C++ and the danger with an article like this is someone might actually follow this advice, instead of eg: the core guidelines.

Every other example is a violation of the core guidelines in some form or another. There is no other problem.



Don't know why I got sniped into this on a friday night, but here's clang-tidy with only cppcoreguideline checks enabled, against every example:

First example: https://godbolt.org/z/898rorEqG

Second example: https://godbolt.org/z/K6aceesG9

Third example: https://godbolt.org/z/KcbqzMzdK

and I can't get the fourth example to compile without fixing the problems.




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

Search: