Why constexpr specifier on function declaration should match with definition if it makes sense only on definitions, i.e. function with only declaration visible in TU can not be constexpr
Why constexpr specifier on function declaration should match with definition if it makes sense only on definitions, i.e. function with only declaration visible in TU can not be constexpr
Since the standard requires any compatible implementations obey that
[dcl.constexpr] p1
If any declaration of a function or function template has a constexpr or consteval specifier, then all its declarations shall contain the same specifier.
This means it does not only require the constexpr specifier should appear in each declaration of the function in one TU but also that in every TU. If there is no otherwise specification, a declaration can also be a definition.
There was bug in my compiler implementation.
constexpr at namespace scope has internal linkage by default, so
function with only declaration visible in TU
produces link error.