<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/95490>95490</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Parametric `enum`s print as `<incomplete type>` in gdb
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
chriselrod
</td>
</tr>
</table>
<pre>
```c++
template <typename T> struct StrongWrapper {
enum class StrongType : T {};
};
using StrongType = StrongWrapper<unsigned int>::StrongType;
int main() {
auto c = StrongType{42};
return 0;
}
```
Saving as `strong_type.cpp`, compiling and running under gdb...
```
~/D/p/c/e/misc $ clang++ -g -std=c++20 strong_type.cpp
~/D/p/c/e/misc $ gdb ./a.out
GNU gdb (Fedora Linux) 14.2-2.fc40
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
No symbol table is loaded. Use the "file" command.
Breakpoint 1 (abort) pending.
Reading symbols from ./a.out...
(gdb) break main
Breakpoint 2 at 0x40111b: file strong_type.cpp, line 8.
(gdb) r
Starting program: /home/chriselrod/Documents/progwork/cxx/experiments/misc/a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Breakpoint 2, main () at strong_type.cpp:8
8 auto c = StrongType{42};
Missing separate debuginfos, use: dnf debuginfo-install libgcc-14.1.1-5.fc40.x86_64 libstdc++-14.1.1-5.fc40.x86_64
(gdb) n
9 return 0;
(gdb) p c
$1 = <incomplete type>
(gdb) q
~/D/p/c/e/misc $ g++ -g -std=c++20 strong_type.cpp (base)
~/D/p/c/e/misc $ gdb -q ./a.out (base)
No symbol table is loaded. Use the "file" command.
Breakpoint 1 (abort) pending.
Reading symbols from ./a.out...
(gdb) break main
Breakpoint 2 at 0x40110a: file strong_type.cpp, line 8.
(gdb) r
Starting program: /home/chriselrod/Documents/progwork/cxx/experiments/misc/a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Breakpoint 2, main () at strong_type.cpp:8
8 auto c = StrongType{42};
Missing separate debuginfos, use: dnf debuginfo-install libgcc-14.1.1-5.fc40.x86_64 libstdc++-14.1.1-5.fc40.x86_64
(gdb) n
9 return 0;
(gdb) p c
$1 = 42
```
So using `g++` prints easy-to-debug enums, while `clang++` requires manual `(int)c` casting, which becomes cumbersome if one (for example) has a struct with many such fields.
I tried defining a gdb pretty printer as a work around, but it doesn't seem to work for struct fields, only the isolated struct.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsV0tv2zoW_jX05sCCTMmvhRdOXAUFMpmiTVHMqqDEY4lTilRJKrY389sHh5LjOAluu7ibCxQIYps8z-88KbxXtUHcsPkNm-8mog-NdZuqccqjdlZOSitPG7ZIh7-K8Rv6S3cs3QZsOy0CAstuw6lDI1qER5Z9AB9cXwX4Epw19Tcnug4dsOXIB4Cmb6HSwvuR5vHUkZgtPEay5Y5lI_HL771Xpr7m2F0rYdltb6JLEpQJLPvAsi3Ltheei-D4X5kArVCG8RXj65c2ij5YqF6oiNzLm5y_NAnAYeidgfTK4uHLGbXh5xfxROYLD2yR-ijyO8GWVF1HRPwWKtt2SkcqI8H1xtD33kh0UMsySZJ3Jf-P8WLHeNExXlSMF8h40SpfAeM5wWzqIWwwrWHqg2TZbgwkT-G1Jb-WWMsSEsYLkdg-DPR3D1_jMeOrAqV1Au6V6Y8E6SxP-JQn-yofrb213cmpuglEfUskPOUZFA4Rvth9OAiHUNjeSB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