Do objects of built-in types have special static initialisation order precedence?

前端 未结 4 546
梦如初夏
梦如初夏 2021-01-18 10:42

I\'d have expected the following code to yield a segmentation fault (or otherwise UB):

struct T {
   T();
};

T t;
char const* str = \"Test string\";

T::T()         


        
4条回答
  •  南笙
    南笙 (楼主)
    2021-01-18 11:17

    Built-in types aren't initialised at all, in the normal sense. Commonly, their initial contents are memory-mapped directly from a special region of the binary as part of loading it.

提交回复
热议问题