title: C++11 non-static data member uniform initialization fails for pointers to other classes of same base class
body: <p>I'm an old C-dude that tries to learn about C++11 by porting my old state-machine framework from C to C++11. My idea is to have a class for the state-machine itself and then nested classes for the states within. The states may be hierarchical, i.e. super- and substates. The framework needs to know about a state's superstate and for that I have a pointer (<code>state *superstate</code>) in the nested state class. </p>
  
  <p>My problem is that I intended to set the superstate-pointer by using the constructor directly within the machine's class, which should be possible in C++11 with non-static data member initialization, by using uniform initialization. But some reason it fails to compile (<code>substateB3{superstateA}</code>) when set to another type of state/class. But it works fine if I later set it by using a specific function (<code>set_superstate</code>) for this purpose, which has the same argument as the constructor! And funny enough the constructor is accepted if I set the superstate to a state/class of same type (<code>substateB2{substateB1}</code>).</p>
  
  <p>I'm using gcc 4.7.0 (to get support for non-static data member initializers) and here's my code:</p>
  
  <pre><code>// My state-machine framework (simplified)
  struct machine {
    struct state {
      state()                  : superstate(nullptr) { }     // No superstate =&gt; toplevel state!
      state(state &amp;superstate) : superstate(&amp;superstate) { }
      state *superstate;
      void set_superstate(state &amp;superstate) { this-&gt;superstate = &amp;superstate; } // Non-ctor way to set superstate
    };
  };
  
  // An example of a specific state-machine using my framework
  struct Machine : machine {
    struct SuperstateA : state {
    } superstateA;
  
    struct SubstateB : state {
    } substateB1,              // Compiles OK; gets its superstate set in Machine's ctor below
      substateB2{substateB1},  // Compiles OK; but not correct superstate
      substateB3{superstateA}; // gcc 4.7.0 error: could not convert ‘{((Machine*)this)-&gt;Machine::superstateA}’ from ‘&lt;brace-enclosed initializer list&gt;’ to ‘Machine::SubstateB’
  
    Machine()  { substateB1.set_superstate(superstateA); } // Compiles OK;
  } myMachine;
  </code></pre>
  
  <p>Any tips or guidance are much appreciated thanks! :)</p>