-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[clang] Define the __cpp_consteval
macro now that support is complete
#57094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@llvm/issue-subscribers-clang-frontend |
There are still some bugs in the implementation so i think it made sense to be conservative in 15 but we should strive to add the macro in clang 16. |
@llvm/issue-subscribers-c-20 |
I agree -- we're close to being complete, but I think there's still some outstanding bugs we should address before we provide the macro. That said, we might discover new bugs by enabling the macro and trying out some large projects (in case anyone is looking for an experiment to run and report back on). |
I did some investigating and we're not as close as I'd like to be. Specifically, there are a few outstanding cases from P1073R3 that we don't handle properly:
There is some implementation divergence, but I believe Clang's behavior is the least conforming of the implementations tested: https://godbolt.org/z/soMs4aWGo |
FWIW, I posted https://reviews.llvm.org/D144572 to try to update the public status page and get more info into the test suite as to what functionality is still missing before we should claim full support (IMO). |
I'm looking into these. |
Here is an attempt to fix the first one - https://reviews.llvm.org/D145251 . |
Regarding the following example:
I think clang is correct here. https://wg21.link/p1937 proposes that in unevaluated contexts, consteval @AaronBallman , is my understanding correct once the two outstanding cases (#57094 (comment) ) are fixed, clang can claim support for consteval again? |
You're correct, good catch!
I think so. Looking through our open issues, I'm not seeing anything that seems like a blocker (though I am seeing plenty of bugs we need to address) and I'm not aware of any outstanding C++20 era issues. It might be nice to ensure the |
I submitted https://reviews.llvm.org/D145251 and https://reviews.llvm.org/D145362 , looking if there is any remaining problems with examples from the standard. |
I just checked the standard and didn't spot any other examples we weren't handling properly. I also looked through the open issues in Clang, and here are the ones that concern me still: #60286 (missing copy elision during constant evaluation, rejects valid code) There were a few others that could be worrisome, but they need further reduction and analysis to be sure. IMO, we don't have to be bug-free but we shouldn't knowingly reject or crash on valid code either. AFAIK, those are the only two outstanding issues that I think qualify as blockers for the feature test macro. If others know of issues they think should also block this, please speak up! |
Notwithstanding the definition of the macro, it seems that after these PRs, the status of P1073R3 on https://clang.llvm.org/cxx_status.html should go back to "Full" (resp. "Unreleased")? (I'm writing here as there's no separate issue for P1073 AFAICT) |
Yes, in general I think the feature test macro and the feature status page should be in agreement. So once we define the macro, we should claim support on the webpage. |
My point was that (IIUC...) P1073 has a much smaller scope than all of C++20 |
TBH, I was naïvely going by the tests you had added in https://reviews.llvm.org/D144572, which have now been fixed. But that's possibly because I had the apparently wrong impression that the |
Well, it sort of does, but here's my thinking: P1073 is what first introduced the idea of consteval functions and the Big Idea from that feature is to force expression evaluation to never be deferred to runtime (always computed at compile time or you get an error). So because we still defer some consteval evaluations to runtime accidentally, it doesn't seem like we should claim to support P1073 quite yet. But it's a value judgement because bug-free is an almost unattainable bar -- so if someone has a counter-argument, we should definitely explore it. |
So, a little update @AaronBallman , do you think we're ready to claim the full support again? |
Thank you for these fixes!
Yes, I think we are. Would you mind putting up a patch to define |
Sure! |
Commit 3d2629d marked
consteval
support as completed for the Clang 15 release in the docs. However, the__cpp_consteval
feature test macro is still not defined. If the feature is indeed production-ready, it would be nice to define this macro, both onmain
and the release branch.llvm-project/clang/lib/Frontend/InitPreprocessor.cpp
Line 679 in 0b12f77
cc @cor3ntin, @ChuanqiXu9
See also #53906
The text was updated successfully, but these errors were encountered: