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

            Bug ID: 51282
           Summary: Type deduction loses alignment
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangb...@nondot.org
          Reporter: erich.ke...@intel.com
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

Example: 
https://godbolt.org/z/q7W5csMnc

typedef signed char int8x8_t __attribute__ ((aligned(16)));                     

int8x8_t foo();            
void baz(const int8x8_t &a);                                                    

void bar()                                                                      
{                                                                               
  const int8x8_t a = foo();                                                     
  baz(a);
  alignas(16) const auto b = foo();  
  baz(b);
}    


The warning is:
<source>:11:7: warning: passing 1-byte aligned argument to 16-byte aligned
parameter 1 of 'baz' may result in an unaligned pointer access
[-Walign-mismatch]
  baz(b);

I debugged this down to the beginning of
SemaTemplateDeduction.cpp::DeduceTemplateArgumentsByTypeMatch.  The
S.Context.getCanonicalType(ArgIn) line loses the typedef (which seems
intentional, based on the comment above it).

However, this also loses the alignment attached to the typedef.

Note that the 'alignas' is also lost, but is not necessarily part of this
example.  With/without it, we still get the warning because 'b' doesn't pick up
the alignment.

I would think about just fixing up the alignment in
DeduceTemplateArgumentsByTypeMismatch, but I suspect there needs to be a bigger
holistic approach to this.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to