Discussion:
[Bug c++/23103] New: C++ parser doesn't recognize typedefs in template parameters
tromey at sourceware dot org
2018-04-21 04:05:30 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23103

Bug ID: 23103
Summary: C++ parser doesn't recognize typedefs in template
parameters
Product: gdb
Version: 8.0.1
Status: NEW
Severity: normal
Priority: P2
Component: c++
Assignee: unassigned at sourceware dot org
Reporter: tromey at sourceware dot org
Target Milestone: ---

Consider this test case:


====
template<typename T> struct S { T val; };

typedef unsigned char uchar;

S<uchar> global { 23 };

int main()
{
return 0;
}
====

Compile with -g and break on the return and:

(gdb) p sizeof(S<uchar>)
No symbol "S<uchar>" in current context.
(gdb) p sizeof(S<unsigned char>)
$1 = 1

Both of these should work.
--
You are receiving this mail because:
You are on the CC list for the bug.
weimin.pan at oracle dot com
2018-10-17 21:56:15 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23103

weimin.pan at oracle dot com changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |weimin.pan at oracle dot com

--- Comment #1 from weimin.pan at oracle dot com ---
Looks like a compiler problem which didn't emit a DW_TAG_typedef tag
for "uchar" for the template type parameter:

<1><2d>: Abbrev Number: 2 (DW_TAG_base_type)
<2e> DW_AT_byte_size : 1
<2f> DW_AT_encoding : 8 (unsigned char)
<30> DW_AT_name : (indirect string, offset: 0x0): unsigned char
...
<2><4c>: Abbrev Number: 5 (DW_TAG_template_type_param)
<4d> DW_AT_name : T
<4f> DW_AT_type : <0x2d>

Instead it should generate something like:

<1><2d>: Abbrev Number: 2 (DW_TAG_typedef)
<2e> DW_AT_name : (indirect string, offset: 0x0): uchar
<34> DW_AT_type : <0x38>
...
<1><38>: Abbrev Number: 3 (DW_TAG_base_type)
<39> DW_AT_byte_size : 1
<3a> DW_AT_encoding : 8 (unsigned char)
<3b> DW_AT_name : (indirect string, offset: 0x31): unsigned char
...
<2><4c>: Abbrev Number: 5 (DW_TAG_template_type_param)
<4d> DW_AT_name : T
<4f> DW_AT_type : <0x2d>
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...