Forwarded from &'a ::rynco::UntitledChannel (Rynco Maekawa)
md 编译个东西碰到了一个十年没修的 clang bug
TL;DR: 在编译含有函数指针的结构体的时候,clang 有时会把函数指针变成指向空结构体的指针(
如:
偶尔会被编译成
而不是
https://stackoverflow.com/questions/18730620/why-a-function-pointer-field-in-a-llvm-ir-struct-is-replaced-by
https://bugs.llvm.org/show_bug.cgi?id=14920
https://github.com/llvm/llvm-project/issues/15292
TL;DR: 在编译含有函数指针的结构体的时候,clang 有时会把函数指针变成指向空结构体的指针(
{}*
)如:
struct Foo {
int (*foo)(int*);
}
偶尔会被编译成
%struct.Foo = { {}* }
而不是
%struct.Foo = { int* (int*)* }
https://stackoverflow.com/questions/18730620/why-a-function-pointer-field-in-a-llvm-ir-struct-is-replaced-by
https://bugs.llvm.org/show_bug.cgi?id=14920
https://github.com/llvm/llvm-project/issues/15292
Stack Overflow
Why a function pointer field in a LLVM IR struct is replaced by {}*?
I compiled the MUSL C library using Clang 3.3, and dumped the generated LLVM IR files. I found that the FILE struct
struct __FILE_s {
unsigned flags;
unsigned char *rpos, *rend;
int (*...
struct __FILE_s {
unsigned flags;
unsigned char *rpos, *rend;
int (*...