[llvm-bugs] [Bug 51629] New: inconsistent alignment passed for array allocation and deallocation when alignof(cookie) > alignof(T)

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 25 17:12:36 PDT 2021


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

            Bug ID: 51629
           Summary: inconsistent alignment passed for array allocation and
                    deallocation when alignof(cookie) > alignof(T)
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++17
          Assignee: unassignedclangbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Testcase:

```
struct X { ~X(); int c; };
extern int n;
X *p = new X[n];
void f() { delete [] p; }
```

On x86_64, under `-faligned-new=2`, this passes `align_val_t{8}` to `operator
new[]` but passes `align_val_t{4}` to `operator delete[]`.

Presumably we should consistently either always or never take the array
cookie's alignment into account when synthesizing the `align_val_t` argument;
always taking it into account seems like the better choice.

-- 
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/20210826/96567903/attachment.html>


More information about the llvm-bugs mailing list