When P0883R2 was initially implemented in D103769 #pragma clang deprecated didn't exist yet.
We also forgot to cleanup usages in libc++ itself.
This takes care of both.
Differential D115995
[libcxx] Add deprecation notices to macros deprecated in P0883R2 tambre on Dec 18 2021, 12:25 PM. Authored by
Details
When P0883R2 was initially implemented in D103769 #pragma clang deprecated didn't exist yet. This takes care of both.
Diff Detail
Event TimelineComment Actions Should I bump the version listed for P0883R2 to 14.0? This only adds an extra non-mandated deprecation warning.
Comment Actions LGTM mod important comment.
Comment Actions Yes, I suggest we bump it so as to not advertise that we implemented a paper fully when we didn't. LGTM but please update the status page. Thanks a lot for the patch! Comment Actions Okay, now that I'm hitting this in a real codebase, I'm stumped as to what the (WG21 and/or libc++) recommendation is, here. ATOMIC_FLAG_INIT is required up-to-and-including C++17, and then deprecated in-and-above C++20? So if I have code in my codebase today like std::atomic_flag flag_ = ATOMIC_FLAG_INIT; should I change it to std::atomic_flag flag_ = {false}; or std::atomic_flag flag_; or what? How am I supposed to eliminate the deprecation warning? I've thought of
None of these options feel very nice. This is the same situation we had with random_shuffle in C++11: https://stackoverflow.com/questions/27791474/what-are-best-practices-for-simple-random-shuffling-in-code-thats-both-c03-an Comment Actions I don't see why you'd think using the macro would be required. Explictly init to false. If C++20 and higher, then you can rely on the default constructor. Comment Actions AFAICT, on paper, C++17/20 atomic_flag has no constructors
Yeah, the default ctor definitely works in C++20-and-above. Below C++20, the default ctor is on-paper "guaranteed" to be trivial and thus "guaranteed" not to work; but it looks like implementations largely ignore that, too, AFAICT, and just do the C++20 thing everywhere (plus the extra constructor from bool which is super helpful). Anyway, I've added -Wno-deprecated-pragma to my build flags for now; that's not as terrible-feeling a workaround as I was worried it would be. And ultimately we'll probably just use the atomic_flag(bool) ctor, even though (AFAICT) it's technically an extension. Comment Actions Ouch, you're correct. I was looking at std::atomic' not std::atomic_flag. Does seem like an oversight. |
Separate macro deprecation macros didn't seem worth it as this is likely to be the only place we'd use them for a while. Since other compilers should simply ignore these guarding these shouldn't be necessary either.