[LLVMbugs] [Bug 8640] New: template diagnostic does not show point of error

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Nov 17 17:29:53 PST 2010


http://llvm.org/bugs/show_bug.cgi?id=8640

           Summary: template diagnostic does not show point of error
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: nlewycky at google.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


Clang should go to the root of template instantiations when virtual functions
are instantiated on 'new'. Here's the testcase:

  template<class T1> struct C1 {
    virtual void c1() {
      T1 t1 = 3;
    }
  };

  template<class T2> struct C2 {
    void c2() {
      new C1<T2>();
    }
  };

  void f() {
    C2<int*> c2;
    c2.c2();      // error here
  }

which produces the following errors:

$ clang++ -fsyntax-only b3205969.cc 
b3205969.cc:3:7: error: cannot initialize a variable of type 'int *' with an
      rvalue of type 'int'
   T1 t1 = 3;
      ^    ~
b3205969.cc:9:8: note: in instantiation of member function 'C1<int *>::c1'
      requested here
   new C1<T2>();
       ^
1 error generated.

Note how we don't actually trace all the way through to the site of the problem
in f(). If you instead changed c1() to be non-virtual then add a call to c1 in
c2() then you would get a note on the line marked "error here" as we expect.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list