[llvm-bugs] [Bug 48236] New: dereferencing __attribute__((noderef)) should not warn inside sizeof() expressions

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 19 15:36:51 PST 2020


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

            Bug ID: 48236
           Summary: dereferencing __attribute__((noderef)) should not warn
                    inside sizeof() expressions
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: jannh at google.com
          Reporter: jannh at google.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

The purpose of __attribute__((noderef)) is to warn about code that will cause
memory to be dereferenced. Currently, clang also warns about code such as:

```
void copy_from_user(void *dst, void __attribute__((noderef)) *src, unsigned
long len);

struct foo {
  int a;
  int b;
};

int test_false_positive_deref(struct foo __attribute__((noderef)) *user_foo) {
  struct foo local_foo;
  copy_from_user(&local_foo, user_foo, sizeof(*user_foo));
  return local_foo.a + local_foo.b;
}
```

noderef checks should be suppressed if isUnevaluatedContext().

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201119/05d642d8/attachment-0001.html>


More information about the llvm-bugs mailing list