Is the default constant variable specific to the internal binding language or compiler?

I read from Bruce Eckel - Introduction to C ++. which says that in C ++ usually a constant variable is not allocated by the store, and their values ​​are stored in the symbol table if EXTERN is not used with a constant or their address is not accepted.

So we can say that in C ++ Const, Internal Linkage is always used by default. but still this function depends on how the compiler is created for the C ++ language. or will it always be true?

+4
source share
1 answer

const By default, global bindings bind to an internal binding. This is indicated by the standard.

const globals should have dedicated storage if you take their address. This is also indicated by the standard.

Just because they sometimes get memory does not mean that the compiler should always use them that way. He can still replace them wherever he wants, and then expressions of constant length.

+6
source

Source: https://habr.com/ru/post/1486226/


All Articles