Hacker News new | past | comments | ask | show | jobs | submit login

Have you ever really used modern C++? This is trivial to avoid and almost never a problem. If it does happen it's immediately clear what went wrong and where since it is in the same scope.



Sure, but is it more trivial to avoid than a compile-time error which literally points you to the exact location where it happens?


It would be better at compile time, but this is one of the things that people who don't use modern C++ think will be a problem and it basically never is. Something happening immediately at run time isn't that far removed from happening at compile time iteration wise.


This is a 10-line example. In real-world code you will get a segfault and then have to hunt through the codebase with a debugging session to figure out where it triggered.


https://devblogs.microsoft.com/cppblog/new-code-analysis-che...

Actually it would trigger the first time you use something after moving and it's pretty obvious what happened because the data structure will have null pointers.

This is very rare and usually just due to a typo in practice because moving a variable in the middle of function is mostly to pass it to another function as an argument so it will be cleaned up when the function is done.

How often does this happen to you? Do you work in modern C++? I've never heard of this actually tripping anyone up.


It's kinda funny to link to a static analysis developed expressly to check for this issue and then claim that the issue isn't a problem in practice, don't you think?


It isn't a problem in practice. I think the static analysis just comes from seeing if they can mimic rust and really nail it down. Just because someone does some static analysis doesn't they are solving a problem that's plaguing people.




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

Search: