<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Expression evaluation for function call to templated class doesn't work"
   href="http://llvm.org/bugs/show_bug.cgi?id=16037">16037</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Expression evaluation for function call to templated class doesn't work
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lldb
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>lldb-dev@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>tareq.a.siraj@intel.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=10528" name="attach_10528" title="Reproducer source">attachment 10528</a> <a href="attachment.cgi?id=10528&action=edit" title="Reproducer source">[details]</a></span>
Reproducer source

Expression evaluation for a function call to a templated class seems to be
broken unless the same expression is used later in the body. Not sure if this
is a duplicate of 15879 or not.

Source:
struct Foo {
};

template <typename T>
class Ptr {
  T Val;

public:
  Ptr() : Val(T()) {}
  Ptr(T x) : Val(x) {}

  T get() const { return Val; }
};

typedef Ptr<Foo*> FooResult;

int main(void) {
  FooResult f = new Foo();
  // Uncommenting the following line seems to work.
  //Foo *p = f.get();
  return 0;
}

To reproduce:
clang++ bug.cpp -o bug -g3 && lldb bug
Current executable set to 'bug' (x86_64).
(lldb) breakpoint set -f bug.cpp -l 21
(lldb) process launch
Process 17771 launched: '/Users/tasiraj/dev/scratch/bug' (x86_64)
Process 17771 stopped
* thread #1: tid = 0x1c03, 0x0000000100000e9f bug`main + 47 at bug.cpp:21, stop
reason = breakpoint 1.1
    frame #0: 0x0000000100000e9f bug`main + 47 at bug.cpp:21
   18        FooResult f = new Foo();
   19        // Uncommenting the following line seems to work.
   20        //Foo *p = f.get();
-> 21        return 0;
   22      }
(lldb) print f
(FooResult) $0 = {
  (Foo *) Val = 0x00000001001000e0
}
(lldb) print f.get()
error: call to a function 'Ptr<Foo*>::get() const' that is not present in the
target
error: The expression could not be prepared to run in the target

versions (OSX):
clang --version
Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.3.0
Thread model: posix

lldb --version
LLDB-179.1

OS: OSX 10.8.3, Linux</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>