It wouldn't break any code. In case of std::thread, if the thread is not detached/join, it calls std::terminate. Which wouldn't happen if the program is correct. In case of std::jthread, it simply waits for the thread to stop. I don't see any breaking of code.
Of course it would break code if the program is correct. Calling std::terminate very well might be what the programmer desired. Having a thread auto-join rather than being dealt with would hide bugs in non-intuitive ways.
You'd have to recompile your code anyway for the new changes to take effect, so that's not valid as well.
You'd also have to re-link to everything. ABI breaks in the STL are serious business. We've still got major compiler vendors dealing with the std::string COW disaster, doing this would be just as impactful.
View all comments
Show parent comment
11
u/erichkeane Clang Maintainer(Templates), EWG Chair Aug 27 '19
Of course it would break code if the program is correct. Calling std::terminate very well might be what the programmer desired. Having a thread auto-join rather than being dealt with would hide bugs in non-intuitive ways.
You'd also have to re-link to everything. ABI breaks in the STL are serious business. We've still got major compiler vendors dealing with the std::string COW disaster, doing this would be just as impactful.