title: ternary operator of different types
body: <p>The following piece of code behaves differently under g++ 4.9.2 and clang++ 3.7.0.  Which one is correct?  What part in standard is related to this?  Thanks.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  struct Base {
    Base() = default;
    Base(const Base&amp;) = default;
    Base(Base&amp;&amp;) = delete;
  };
  
  struct Derived : Base {
  };
  
  int main() {
    const Base&amp; b = true ? Derived() : Base();
  }
  </code></pre>
  
  <p>g++ accepts it and clang++ gives an error <code>incompatible operand types ('Derived' and 'Base')</code>.  See below for details.</p>
  
  <pre><code>[hidden]$ g++ -v
  Using built-in specs.
  COLLECT_GCC=/usr/bin/g++
  COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.9.2/lto-wrapper
  Target: x86_64-redhat-linux
  Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.9.2-20150212/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.9.2-20150212/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
  Thread model: posix
  gcc version 4.9.2 20150212 (Red Hat 4.9.2-6) (GCC) 
  [hidden]$ g++ -std=c++11 b.cpp 
  [hidden]$ clang++ -v
  clang version 3.7.0 (http://llvm.org/git/clang.git 6bbdbba8ec8a7730c68fee94363547dc2dc65b10)
  Target: x86_64-unknown-linux-gnu
  Thread model: posix
  Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/3.4.6
  Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.9.2
  Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.9.2
  Candidate multilib: .;@m64
  Candidate multilib: 32;@m32
  Selected multilib: .;@m64
  [hidden]$ clang++ -std=c++11 b.cpp 
  b.cpp:14:24: error: incompatible operand types ('Derived' and 'Base')
    const Base&amp; b = true ? Derived() : Base();
                         ^ ~~~~~~~~~   ~~~~~~
  1 error generated.
  </code></pre>