[lldb-dev] Evaluate expression for template class

Scott Funkenhauser via lldb-dev lldb-dev at lists.llvm.org
Tue Jul 23 16:22:39 PDT 2019


Hey,

I've noticed that evaluating expressions involving templated classes seems
to have some unexpected behavior.

I've created the following sample code to reproduce the issue:

template <typename T> class foo
{
  uint32_t data;
};

foo<int> test;

int main() {
  foo<void> test2;
  return 0;
}

I've set a breakpoint on main and evaluated the following expressions:
(lldb) p sizeof(foo<void>)
(unsigned long) $0 = 4
(lldb) p sizeof(foo<int>)
error: implicit instantiation of undefined template 'foo<int>'
template is declared here

It seems like expression evaluation can only find the specialized templated
classes that were used in the current scope. Running the same example using
GDB works as expected (both expressions are evaluated correctly).

Is this a known issue?
Does anybody have any insight, or familiarity with expression
evaluation that would be able to point me in the right direction?

Thanks,
Scott
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20190723/fb0cf5a7/attachment.html>


More information about the lldb-dev mailing list