News for hackers. Stuff that matters.
Re:The Sad Truth About C++ Copy Elision by wffurr on Saturday April 03, 2021 @01:25PM (#26682853)
I try to write pretty straightforward modern C++ as well, but have been bitten repeatedly by weird corners of the language. For a recent example, I was using the address of some functions from a library, and the library changed to provide the exact same functions in a different way that broke taking their address.

Seems like that particular Abseil ToTW isn’t public, but it alluded to this practice being banned in the C++ STL.

Or for another example, writing code that can be compiled by different versions of a single compiler, clang, e.g. across the Android NDK, XCode, latest LLVM on Linux, and Emscripten, will occasionally give surprising results. To say nothing of supporting msvc or gcc.

Re:The Sad Truth About C++ Copy Elision by gumby on Saturday April 03, 2021 @03:09PM (#26683793)
Both of your examples hold for C, and for the same reasons. For example trying to take the address of `errno` is UB in C as implementations are free to implement it as a macro (and almost all do).
Re:The Sad Truth About C++ Copy Elision by wffurr on Saturday April 03, 2021 @06:35PM (#26685352)
Good to know, not that I expected C to be any better.