On Fri, Jan 31, 2025 at 11:24:33PM +0900, The Cuthour via Gcc wrote:
> > C++ requires constant expressions to be known during compilation, not
> > at link time.
> 
> A constant that is not determined at compile-time is akin to
> constructor that is const but not constexpr. While it remains
> constant throughout the program, its value is established only
> at link-time, not at compile-time.

That is not valid.
http://eel.is/c++draft/expr.sizeof#note-3
says that sizeof is an integral constant expression, so it can be used in
consteval or constexpr function constant evaluation or in constant
expressions.  You can't defer that to link time evaluation, the exact
values of the constant expressions may affect which templates are
instantiated etc., you'd basically need to defer all the compilation until
link time then.

        Jakub

Reply via email to