title: Accidentially 'instantiate' an abstract class type using brace-initializers?
body: <p>Today I stumbled over the following issue. Someone got a little too fond of brace-initializers and accidentally tried to instantiate an interface class. Bear with me:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class IFoo
  {
  public:
     virtual ~IFoo() = default;
     virtual bool getFoo() const = 0;
  };
  
  void processFoo(const IFoo &amp;fooImpl)
  {
      bool foo = fooImpl.getFoo();
      std::cout &lt;&lt; "got foo " &lt;&lt; foo &lt;&lt; std::endl;
  }
  
  int main()
  {
     processFoo({});  // &lt;- why is this valid?!
     return 0;
  }
  </code></pre>
  
  <p>Until now I'd expected that the compiler would issue an error similar to the one you get when trying something silly like calling <code>IFoo()</code> or <code>IFoo{}</code>. However, the above code compiles without warning (on gcc 6.2) but will obviously terminate with '<strong>pure virtual method called</strong>' as soon as you try to invoke the <code>getFoo()</code> method. <a href="http://coliru.stacked-crooked.com/a/52680e74c9e9ec39" rel="nofollow noreferrer">Live example</a>. </p>
  
  <p>Could somebody kindly explain to me what is going on there? </p>