[cfe-dev] Type suffixes should be generated for non-type template parameters in Debug info.

Roman Popov via cfe-dev cfe-dev at lists.llvm.org
Sat Feb 3 00:38:05 PST 2018


Hello,
I've noticed that Clang does not emits type suffixes to debug info,
so types foo<1u> and foo<1> will be both saved to debug info as foo<1>.

Unfortunately this leaves no chance to debugger to correctly identify
dynamic type. Consider example:

struct base {
    virtual ~base() {}
};

template< auto IVAL>
struct foo : base {
    decltype(IVAL) x = -IVAL;
};

int main()
{
    base * fi = new foo<10>();
    base * fu = new foo<10u>();

//  BREAKPOINT HERE:
    return 0;
}


Running in GDB:

(gdb) p *fi
$1 = (foo<10>) {<base> = {_vptr$base = 0x4009d8 <vtable for foo<10>+16>}, *x
= 4294967286*}

Wrong type!!, x == -10!!

(gdb) p *fu
warning: RTTI symbol not found for class 'foo<10u>'
$2 = warning: RTTI symbol not found for class 'foo<10u>'
warning: RTTI symbol not found for class 'foo<10u>'
{_vptr$base = 0x400a58 <vtable for foo<10u>+16>}

Dynamic type not identified.


-Roman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180203/1f69c3f2/attachment.html>


More information about the cfe-dev mailing list