What does const do at lower levels of the machine?

When creating something constin C ++, which makes it impossible, for example, to implicitly pass it non-constant at lower levels of the machine? How is a machine determined, what is it const?

(besides what it constmeans what it means ...)

Perhaps it is stored in the .rdata section of memory, or is there a bit that gets set, which makes it const, or how does it work?

Can anyone clarify?

+5
source share
4 answers

const- This is mainly compilation time; this does not mean anything about where they can be stored at run time, or they can be protected at run time.

, ( ). , .

, .

+12

const -ness , , . .

: @ .

+8

"const" , . , ++ (, , ). , .

, "const volatile" ( , ). , .

, " " . - , , .

+3

++, const, - . , .

The only exception is static constant variables of the primitive type or the POD type, which are usually associated with a read-only section in the executable sample and will cause some kind of error in the page if you drop the constant and try to change one of them.

+1
source

All Articles