<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - [DebugInfo] Wrong representation of enumerator values in debug info metadata"
href="https://bugs.llvm.org/show_bug.cgi?id=36168">36168</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[DebugInfo] Wrong representation of enumerator values in debug info metadata
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>momchil.velikov@arm.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=19780" name="attach_19780" title="C language test case">attachment 19780</a> <a href="attachment.cgi?id=19780&action=edit" title="C language test case">[details]</a></span>
C language test case
There are a few issue with the representation of enumeration types in the debug
info metadata as well as in DWARF.
The representation of enumerator values uses a single `int64_t`, which does not
convey enough information about the enumerator value. For example, when
compiling
the attached `e.c`, `clang` encodes the values of `A5` and `A7` wrong in the
DWARF debug info:
```
$ clang -c -g e.c && llvm-dwarfdump --debug-info e.o | grep -A1 A[0-9]
DW_AT_name ("A0")
DW_AT_const_value (-128)
--
DW_AT_name ("A1")
DW_AT_const_value (255)
--
DW_AT_name ("A2")
DW_AT_const_value (-32768)
--
DW_AT_name ("A3")
DW_AT_const_value (65535)
--
DW_AT_name ("A4")
DW_AT_const_value (-2147483648)
--
DW_AT_name ("A5")
DW_AT_const_value (-1)
--
DW_AT_name ("A6")
DW_AT_const_value (-9223372036854775808)
--
DW_AT_name ("A7")
DW_AT_const_value (-9223372036854775808)
```
Compiling the same program as C++ and using the `-fshort-enums` gets wrong the
value of A3 as well:
<span class="quote">> $ clang -fshort-enums -x c++ -c -g e.c && llvm-dwarfdump --debug-info e.o | grep -A1 A3
> DW_AT_name ("A3")
> DW_AT_const_value (-1)
> </span >
Similar issues are present with C++11 enumerations with a fixed underlying
type, e.g. compiling the attached `e.cc`, yields wrong values for `A1`, `A3`,
`A5`, and `A7`:
```
$ clang -c -g e.cc && llvm-dwarfdump --debug-info e.o | grep -A1 A[0-9]
DW_AT_name ("A0")
DW_AT_const_value (-128)
--
DW_AT_name ("A1")
DW_AT_const_value (-1)
--
DW_AT_name ("A2")
DW_AT_const_value (-32768)
--
DW_AT_name ("A3")
DW_AT_const_value (-1)
--
DW_AT_name ("A4")
DW_AT_const_value (-2147483648)
--
DW_AT_name ("A5")
DW_AT_const_value (-1)
--
DW_AT_name ("A6")
DW_AT_const_value (-9223372036854775808)
--
DW_AT_name ("A7")
DW_AT_const_value (-9223372036854775808)
```</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>