Question Details

No question body available.

Tags

c++ visual-c++ lambda constants void-pointers

Answers (1)

February 22, 2026 Score: 2 Rep: 72,541 Quality: Low Completeness: 40%

In C++20, even if a variable is constexpr, if you take its address or pass an array (which decays to a pointer), it is "ODR-used." This requires the variable to be captured.

void f(const void*) {}

int main() { constexpr float one[1] = { 1.0f };

// Capture the pointer to the array explicitly [ptr = one]() { f(ptr); f(&ptr[0]); }(); }