Skip to content

[LoongArch] ABI mismtach between clang++ and g++ against empty union #70890

@SixWeining

Description

@SixWeining
  • Testcase
// foo.h
union U {
};

struct B {
  U u;
  int i;
  double d;
};

int test(B b);
// foo.cpp 
#include "foo.h"

int test(B b) {
  return b.i;
}
// main.cpp 
#include "foo.h"

int main() {
  B b;
  b.i = 10;
  return test(b);
}
  • build and run
$ g++ -c foo.cpp -o foo.o
$ clang++ -c main.cpp -o main.o
$ clang++ foo.o main.o -o main
$ ./main
$ echo $?
0 (expected 10, but actual 0)
  • compiler versions
$ g++ --version
g++ (GCC) 13.0.0 20221013 (experimental)

$ clang++ --version
clang version 18.0.0 (https://github.com/llvm/llvm-project.git 1abd8d1a8d962a14ca96e19c0f6da4f9ac394d0a)
Target: loongarch64-unknown-linux-gnu
Thread model: posix

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions