I'm taking addresses of the following instantiated variable templates from two translation units:
template<class T> bool b = true;
template<class T> const bool cb = true;
template<class T> inline const bool icb = true;
I'm printing addresses of b<int>
, cb<int>
and icb<int>
. Here is what clang says:
0x6030c0 0x401ae4 0x401ae5 // first translation unit
0x6030c0 0x401ae4 0x401ae5 // second translation unit
All addresses are the same, kind of expected. And here is what gcc says:
0x6015b0 0x400ef5 0x400ef4 // first translation unit
0x6015b0 0x400ef6 0x400ef4 // second translation unit
The address of cb<int>
changes. Huh? Is this a bug? If not, could someone please explain this effect to me?