[cfe-users] dynmaic_cast in uninstantiated function templates

via cfe-users cfe-users at lists.llvm.org
Fri Oct 19 05:47:29 PDT 2018


Hi list,

the code below compiles on gcc and icc, but not on clang with the error:

source_file.cpp:14:16: error: 'B' is an incomplete type
  if (auto b = dynamic_cast<B*>(a))

However fn is an uninstantiated function template. 
Is this a glitch in clang or is clang the only one right here?

Best Olaf

---begin code ---
#include <ostream> 
#include <iostream> 

class A {};
class B;

void foo(B* b)
{ } 

template<class T>
void fn(A* a, T& x)
{
  if (auto b = dynamic_cast<B*>(a))
  {
    foo(b);
  }
}

int main()
{
  std::cout << "Hello World\n";
}

    







More information about the cfe-users mailing list