[llvm-bugs] [Bug 45890] New: alignof(reference_to_type) doesn't return alignof(referenced_type) as it ought to, by the standard

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 12 14:51:33 PDT 2020


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

            Bug ID: 45890
           Summary: alignof(reference_to_type) doesn't return
                    alignof(referenced_type) as it ought to, by the
                    standard
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: sinbal2l at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

>From the C++ standard:

7.6.2.5 Alignof [expr.alignof]p3

3 When alignof is applied to a reference type, the result is the alignment of
the *referenced* type.  

IINM, in the latest version, the returned value is of the reference itself:

#include <stdio.h>

int main() {
    alignas(32) double d;
    double &ref_d = d;

    printf("Alignment of d: %d\n", alignof(d));             // 32
    printf("Alignment of ref_d: %d\n", alignof(ref_d));     // 8
}


https://godbolt.org/z/MnG6vb

P.S. thank you very much for doing such a great job! (2) (43353)

-- 
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/20200512/f676519a/attachment.html>


More information about the llvm-bugs mailing list