[lldb-dev] [Bug 47524] New: Calling functions with a null pointer-to-typedef-of-anonymous-struct argument fail

via lldb-dev lldb-dev at lists.llvm.org
Mon Sep 14 06:30:52 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47524

            Bug ID: 47524
           Summary: Calling functions with a null
                    pointer-to-typedef-of-anonymous-struct argument fail
           Product: lldb
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at lists.llvm.org
          Reporter: jarin at google.com
                CC: jdevlieghere at apple.com, llvm-bugs at lists.llvm.org

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
```

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20200914/9bbb7c3c/attachment.html>


More information about the lldb-dev mailing list