Closed
Description
Affected rules
A7-1-2
Description
A constexpr
function only returns a compile-time constant when provided with compile-time constants as arguments. The query currently incorrectly considers constexpr
functions to always return constants.
Example
This function should only be considerd
constexpr int add(int x, int y) {
return x + y;
}
void test(int p) {
int x = add(1,2); // NON_COMPLIANT - could be marked constexpr
int y = add(1,p); // COMPLIANT - cannot be marked constexpr