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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

>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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to