Remix.run Logo
w4rh4wk5 3 hours ago

I've been wondering about debug-ability of code using reflection. X-Macros are quite annoying to step through in most debuggers, though possible. While the code in the first example is evaluated fully at compile-time, how would you approach debugging it?

SuperV1234 an hour ago | parent | next [-]

Nothing that makes it straightforward. Testing via `static_assert` is a good strategy, but it's not debugging. I believe there are some ways of printing custom diagnostics during compilation, but I am not aware of any step-by-step debugging tool that runs at compile-time.

In practice, I haven't really needed to ever debug `consteval` functions -- it's quite easy to get the right behavior down thanks to `static_assert`-based testing and thanks to the fact that they do not depend on external state (simpler).

cenamus 2 hours ago | parent | prev [-]

I mean it's still C++ that's compiled and executed, surely the compiler would be able to provide a way to hook into that?

usefulcat an hour ago | parent [-]

I don't recall the source, but I don't believe most (any?) c++ compilers implement compile-time code evaluation by compiling and running code.

For one thing they are required to disallow all undefined behavior for compile time execution, and some forms of UB only occur when the code is run.