Why implicit free's declaration is taken vararg parameter in llvm

Refresh

4 weeks ago

Views

3 time

0

Taken the following code

int main() {
  int* a = (int*) malloc(sizeof(int) * 10);
  free(a);
  return 0;
}

If compile it to llvm IR by clang -S -emit-llvm -O0 -g, free's declaration is:

declare i32 @free(...) #2

However, if I add #include <stdlib.h>, free's declaration is:

declare void @free(i8*) #2

By adding include, the declaration is obviously taken from the header file, but why implicit free's declaration is different?

0 answers