logoalt Hacker News

OneDeuxTriSeiGolast Tuesday at 9:52 PM0 repliesview on HN

> How do you debug consteval, if you cannot put printf in it?

This will be massively improved in the next std release hopefully since Compile Time Reflection looks like it's finally shipping.

And of course there exist special constexpr debuggers but more generally you really should be validating consteval code with good test suites ahead of time and developing your code such that useful information is exposed via a public (even if internal) interface.

And of course in the worst case throws function as decent consteval printf even if the UX isn't great.

But of course there's more work on improving this in the future. There's a technique I saw demoed at one of the conferences this year that lets you expose full traces in failure modes for both consteval and non-const async code and it seems like it'll be a boon for debugging.

----

> Not everyone can use clang or even latest gcc in their project, or work in a familiar codebase.

Sure note everyone is that lucky but it's increasingly common. AFAIK TI moved entirely to clang based toolchains a few years back and Microchip has done the same. The old guard are finally picking up and moving to modular toolchain architectures to reduce maintenance load and that comes with upstream std support.