usaxena95 added a comment. Herald added a project: All. Hi, I have been trying to get consteval in a better shape.
In D119651#3327212 <https://reviews.llvm.org/D119651#3327212>, @Izaron wrote: > After an investigation in GDB I can say that the assert seems to be wrong. > Since Clang instantiates classes and functions "on the fly" where > appropriate, we indeed can get a run-time evaluation context after a > compile-time evaluation context. I was sure that evaluation contexts were > made to represent a clean hierarchy of context, because they're interrelated, > but the case with instantiations confuses me. Can you rebase and verify if there are still assertion failures. I think the assertion is fair. Dependent immediate function invocations must be done during instantiation. I suspect https://reviews.llvm.org/D132031 might have fixed the issue. > This code ... > > template<int N> > struct good_struct { > // we are in run-time eval context! > static consteval int evalconst() { > // we are in compile-time eval context! > return N * N; > } > > void foo(); > void bar(); > }; > > //int good_struct_100 = good_struct<100>::evalconst(); > //int good_struct_200 = good_struct<200>::evalconst(); > > consteval int consteval_foo() { > // we are in compile-time eval context! > return good_struct<100>::evalconst(); > } > > template</* we are in compile-time eval context! */ int N = > good_struct<200>::evalconst()> > constexpr int templated_foo() { > return N; > } > > ... hits the assert two times, unless we uncomment the lines with > `good_struct_100` and `good_struct_200`. That's because Clang instantiates > the classes when it "sees" them, straight from consteval/template contexts. I > couldn't come up with a correct code that breaks though. > > I am now less sure if the patch (without the assert) is acceptable, what if > the concept of "evaluation contexts" needs a revision?.. Can you also give a reproducer for which you see the assertion failure if you still see this. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D119651/new/ https://reviews.llvm.org/D119651 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits