<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 - Calling functions with a null pointer-to-typedef-of-anonymous-struct argument fail"
href="https://bugs.llvm.org/show_bug.cgi?id=47524">47524</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Calling functions with a null pointer-to-typedef-of-anonymous-struct argument fail
</td>
</tr>
<tr>
<th>Product</th>
<td>lldb
</td>
</tr>
<tr>
<th>Version</th>
<td>11.0
</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>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>lldb-dev@lists.llvm.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jarin@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>jdevlieghere@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>The LLDB expression evaluator fails to evaluate a function call
with a null argument of the pointer to typedef of anonymous struct type.
See below for detailed repro steps. The error message is:
```
error: function 'f' is used but not defined in this translation unit, and
cannot be defined in any other translation unit because its type does not have
linkage
```
The problem reproduces on the latest master as well as on LLDB 9 and 10 (have
not tried 11).
It is also interesting to note that the problem goes away after the first
evaluation of the function call with non-null argument (as shown in the
example below). The problem also goes away if I make the struct non-anonymous.
```
$ cat a.cc
typedef struct {
int f;
} S;
S s;
int f(S* s) {
return s == nullptr;
}
int main() {
return f(nullptr); // break here, evaluate `f(nullptr)`
}
$ clang -g a.cc
$ lldb --version
lldb version 12.0.0
clang revision 687e1d7121645d23aa5e919ed4d3c0e57af975cd
llvm revision 687e1d7121645d23aa5e919ed4d3c0e57af975cd
$ lldb a.out
...
(lldb) b main
...
(lldb) r
...
-> 12 return f(nullptr);
...
(lldb) p f(nullptr)
error: error: function 'f' is used but not defined in this translation unit,
and cannot be defined in any other translation unit because its type does not
have linkage
<user expression 0>:1:1: used here
f(nullptr)
^
(lldb) p f(&s)
(int) $1 = 0
(lldb) p f(nullptr)
(int) $2 = 1
```</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>