C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Delayed const declaration

From: Sebastian Wittmeier <wittmeier_at_[hidden]>
Date: Sun, 16 Feb 2025 16:59:31 +0100
For int i = 0; const i; std::cout << &i << std::endl; Would the compiler be allowed to optimize out the non-const phase of i and put it into read-only-memory? For int i = 0; std::cout << &i << std::endl; const i; std::cout << &i << std::endl; Would the compiler be allowed to relocate i between non-const memory and read-only-memory and print out two different addresses?

Received on 2025-02-16 16:03:45