title: Visual Studio 2013 'explicit' keyword bug?
body: <p>Consider the following program:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class A
  {
  public:
    A( ) { std::cout &lt;&lt; "A()\n"; }
  
    A( A&amp; ) = delete;
  
    A( int i ) { std::cout &lt;&lt; "A( " &lt;&lt; i &lt;&lt; " )\n"; }
  
    explicit operator int( ) { std::cout &lt;&lt; "operator int()\n"; return 42; }
  };
  
  template&lt; typename T = A &gt; void f( T a = A() ) {}
  
  int main( void )
  {
    f();
    return 0;
  }
  </code></pre>
  
  <p>Visual Studio 2013 compiles this code and runs, with output</p>
  
  <pre><code>A()
  operator int()
  A( 42 )
  </code></pre>
  
  <p>Is this a compiler bug? It looks like the VS compiler doesn't heed the 'explicit' keyword in this context. From my understanding, VS 2013 wrongly uses operator int() in combination  with A(int) to sort-of 'copy-construct' A as the default parameter for f.</p>
  
  <p>Both adding</p>
  
  <pre><code>A a;
  A a1( a );
  </code></pre>
  
  <p>to main and declaring f as</p>
  
  <pre><code>void f( A a = A() ) {}
  </code></pre>
  
  <p>does not compile, VS complains that A(A&amp;) is deleted, which seems to be correct behavior. Only in the context of the function template default parameter the combination of operator int() and A(int) seem to work as a substitution for A( A&amp; ).</p>
  
  <p>g++ 4.7.3 does not compile the code and complains:</p>
  
  <pre><code>main.cpp: In function ‘int main()’:
  main.cpp:21:7: error: no matching function for call to ‘A::A(A)’
  main.cpp:21:7: note: candidates are:
  main.cpp:10:3: note: A::A(int)
  main.cpp:10:3: note:   no known conversion for argument 1 from ‘A’ to ‘int’
  main.cpp:6:3: note: A::A()
  main.cpp:6:3: note:   candidate expects 0 arguments, 1 provided
  </code></pre>
  
  <p>Removing 'explicit' makes g++ compile the code and the output is the same.</p>