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

            Bug ID: 47499
           Summary: __unaligned extension inconsistent behaviour with C
                    and C++
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangb...@nondot.org
          Reporter: rofir...@gmail.com
                CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
                    richard-l...@metafoo.co.uk

struct Foo {
  unsigned long x;
};

void foo(__unaligned struct Foo* out){
  out->x = 5;
}

Emits this in C (which is the expected behaviour)

%struct.Foo = type { i64 }

define dso_local void @foo(%struct.Foo* nocapture %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds %struct.Foo, %struct.Foo* %0, i64 0, i32 0
  store i64 5, i64* %2, align 1, !tbaa !2
  ret void
}

but this in C++ which does not honour the qualifier

%struct.Foo = type { i64 }

define dso_local void @_Z3fooPU11__unaligned3Foo(%struct.Foo* nocapture %0)
local_unnamed_addr #0 {
  %2 = getelementptr inbounds %struct.Foo, %struct.Foo* %0, i64 0, i32 0
  store i64 5, i64* %2, align 8, !tbaa !2
  ret void
}

We want both languages agree. I suggest we bring the current behaviour in C to
C++.

-- 
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