Answer the question
In order to leave comments, you need to log in
Service for learning c++ code (+ another question about constexpr as an example)?
A service is needed that could demonstrate the inner workings of the libraries, the compiler, and real-time memory allocation. Something like https://godbolt.org/ - but this service is more about the compiler device and assembler (of course). I am interested in a service where in real time, when executing the code, it will be possible to watch all internal calls between libraries and built-in types.
Let me give you a more specific example. It is not clear to me how memory is allocated for constexpr class objects, because it is not clear how the size of the class is calculated (no, of course the size of the class is the sum of the sizes of all its members - variables, etc.), but the process and sequence of allocation is not clear in memory, in the sense that if I create a constexpr object of a derived class, then the compiler will go to this class - calculate its size and it turns out that it will be forced to calculate the size of the base class, which is not constexpr?
But as far as I know, if something in a constexpr expression is non-constexpr - then the whole expression becomes non-constexpr?
For example:
constexpr int inc (int a)
{
return a + 1;
}
void func()
{
int a = inc (3);
constexpr int b = inc (a); // ошибка: a не является constexpr-выражением, из-за чего возвращаемое значение не имеет спецификатор constexpr
}
Answer the question
In order to leave comments, you need to log in
You are trying to do unnecessary and meaningless work.
The first argument is that all C ++ compilers are arranged differently and their internal kitchen changes a lot from version to version. I remind you that C++ doesn't even have a stable ABI
. Further, most of the C++ libraries are templates that, when compiled, turn into wild stuffing with a bunch of optimizations. So if you understand something there in one case, it will not give you information about how it will work in other cases.
If something non-constexpr appears inside a constexpr, the compiler will send you to the ban. And he will do it right.
All guarantees about C++ are only in the standard. Other attempts to make arguments about how the compiler works and how the binary works will most likely be fantasies or special cases that do not apply in other situations or with different optimization settings.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question