Date: Fri, 26 Jan 2024 14:14:55 +0100
> As far as the C++ standard is concerned, it is. More precisely, it
happens before dynamic initialization and running main(), i.e. before
any of the program's code runs.
Yes, and that is still run-time. Just because it happens before
dynamic initialization doesn't make it not run-time. The process of
running the executable and mapping memory is obviously run-time, not
compile-time. You're arbitrarily drawing a line before dynamic
initialization and saying that all the run-time work the operating
system does up to that point is not run-time ... because ...uhm?
> So, as far as the standard is concerned, the object could as well exist eternally.
No, it would not be valid. This would imply that the object's address
is also eternally a constant, but the address can be different each
time the program runs. The only thing that's guaranteed is that the
value it is initialized with AT RUN-TIME is constant.
> I disagree. I don't think that diluting the meaning of constinit is a good idea ...
That's understandable. This is the biggest hurdle for any such
proposal; I'm sure there would also be voices in the committee saying
more or less the same.
happens before dynamic initialization and running main(), i.e. before
any of the program's code runs.
Yes, and that is still run-time. Just because it happens before
dynamic initialization doesn't make it not run-time. The process of
running the executable and mapping memory is obviously run-time, not
compile-time. You're arbitrarily drawing a line before dynamic
initialization and saying that all the run-time work the operating
system does up to that point is not run-time ... because ...uhm?
> So, as far as the standard is concerned, the object could as well exist eternally.
No, it would not be valid. This would imply that the object's address
is also eternally a constant, but the address can be different each
time the program runs. The only thing that's guaranteed is that the
value it is initialized with AT RUN-TIME is constant.
> I disagree. I don't think that diluting the meaning of constinit is a good idea ...
That's understandable. This is the biggest hurdle for any such
proposal; I'm sure there would also be voices in the committee saying
more or less the same.
Received on 2024-01-26 13:15:07