JuliaHubOSS / llvm-cbe

resurrected LLVM "C Backend", with improvements
Other
832 stars 141 forks source link

return type of 'main' is not 'int' #79

Closed robiwano closed 3 years ago

robiwano commented 3 years ago

With even the simplest code:

#include <stdio.h>
int main()
{
  printf("Hello World!\n");
  return 0;
}

I get the following warning:

src/CMakeFiles/llvm_cbe_poc.dir/main.c:802:1: warning: return type of 'main' is not 'int' [-Wmain-return-type]
uint32_t main(void) __ATTRIBUTELIST__((noinline));
^

but the LLVM file clearly states:

; Function Attrs: noinline norecurse optnone uwtable
define dso_local i32 @main() #0 { 
...
}

How is the i32 converted to uint32_t ?

vtjnash commented 3 years ago

LLVM doesn't preserve sign (since the ABI doesn't either), so everything is emitted as unsigned. It does cause these annoying warnings, but I think should be the same build.