[llvm-bugs] [Bug 46947] New: Confusing misaligned atomic operation warning

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Aug 1 05:27:14 PDT 2020


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

            Bug ID: 46947
           Summary: Confusing misaligned atomic operation warning
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: schuett at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

For the following code, I get an error:
repro.cpp:13:3: warning: misaligned atomic operation may incur significant
performance penalty [-Watomic-alignment]
  __atomic_load(&foo->bar, &dummy, __ATOMIC_RELAXED);

clang believes that the pointer is 8 byte aligned, but foo->bar is actually 16
byte aligned.

#include <cstdint>

struct Foo {
  struct Bar {
    uint64_t a;
    uint64_t b;
  };
  Bar bar;
};

void braz(Foo *foo) {
  Foo::Bar dummy;
  __atomic_load(&foo->bar, &dummy, __ATOMIC_RELAXED);
}

-- 
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/20200801/79da9e7e/attachment-0001.html>


More information about the llvm-bugs mailing list