C++17 constexpr everything, or as much as the compiler can
11–20 of 120 posts
Re: C++17 constexpr everything, or as much as the compiler can
#12Genuine question: Is there anything protecting us from an entirely new class of compiler bugs where the constexpr code and the compiled code behave differently? Is it at all possible?
Of course it is possible. Just consider all the registers, memory locations changed during the execution of such functions. Such side effects can affect behaviour of other code in the presence of compiler bugs.
Re: C++17 constexpr everything, or as much as the compiler can
#13In C++, to debug failed constexpr’s, often, you have to make it a non-constexpr and debug at runtime.
Re: C++17 constexpr everything, or as much as the compiler can
#14What about debugging? If the code to generate the data is large and complex, how do you debug it when it only runs at compile time? Is the solution to start with two programs like the author and then merge them? That still seems like a maintainability issue.
You could use something like #ifdef NDEBUG #define MY_CONSTEXPR #else #define MY_CONSTEXPR constexpr so when you are running the debug build, everything is debuggable.
Re: C++17 constexpr everything, or as much as the compiler can
#15 max-inline-recursive-depth
max-inline-recursive-depth-auto
Specifies the maximum recursion depth used for recursive inlining.
For functions declared inline, --param max-inline-recursive-depth is taken into
account. For functions not declared inline, recursive inlining happens only when
-finline-functions (included in -O3) is enabled and --param
max-inline-recursive-depth-auto is used. The default value is 8.Re: C++17 constexpr everything, or as much as the compiler can
#16ad hoc partial evaluation ?
I don't see how the C++ community will benefit from those, since the type of code that benefits is normally done in other languages. But I am certainly less creative than a community.
Re: C++17 constexpr everything, or as much as the compiler can
#17C++ is never just C++. The build system for any C++ program includes both macro language and some form of make and/or make replacement. Explicitly generating tables at compile time and linking is bog standard at this point. Write a table generator program, have output create a table, splice in the order into make and/or make replacement. Sure it's three extra steps, but it's small steps that can be debugged. It also…
Re: C++17 constexpr everything, or as much as the compiler can
#18What about debugging? If the code to generate the data is large and complex, how do you debug it when it only runs at compile time? Is the solution to start with two programs like the author and then merge them? That still seems like a maintainability issue.
constexpr don't have to run at compile-time, they can do so. So you can use regular tests/debugging to debug your function.
Re: C++17 constexpr everything, or as much as the compiler can
#19I don't get this. Why? Doesn't making a variable constexpr ensure it is a compile time value, or it will fail to compile?
Re: C++17 constexpr everything, or as much as the compiler can
#20C++ is never just C++. The build system for any C++ program includes both macro language and some form of make and/or make replacement. Explicitly generating tables at compile time and linking is bog standard at this point. Write a table generator program, have output create a table, splice in the order into make and/or make replacement. Sure it's three extra steps, but it's small steps that can be debugged. It also…