Two things I'd like to know about how static locals are implemented by the compiler
<p>These are two questions about static locals that have always bothered me and I haven't found a definitive answer to:</p>

<p>Question 1:</p>

<pre><code> struct Test
 {
  static inline const char* name()
  {
     static const char* nameValue = "Name of Test";
     return nameValue;
  }
};
</code></pre>

<p>Since the method is inline, there should be a copy of this method in each compilation unit that calls it. But, there must be only one instance of the local static variable <code>nameValue</code> (correct me if I am wrong). How is this achieved? We have many instances of a function generated, but all of them refer to the same static local. Does the compiler maintain a global table of static locals associated with each function by name?</p>

<p>Question 2:</p>

<pre><code> struct Init
 {
   Init() {printf("init created\n");}
  ~Init() {printf("init destroyed\n");}
 };

 struct Test
 {
   static void func()
   {
       static Init init;
   }
 };
</code></pre>

<p>The static local Init object is constructed only once, on the first call of func(). How does the compiler know when is the first call to func()? Does it maintain a flag at runtime, whether this is the first call of this func?</p>
