First time poster here. I ran into an interesting issue today where clang generates a code which crashes. I know it’s a very common thing among programmers to blame the compiler for their own mistakes, but I think it’s not applicable for this case. I have managed to narrow down the problem to a few lines of code and two compiler options. Here is the code:
float f = 1.0f;
And if you compile it like this:
clang -fPIC -mcmodel=large -o main main.c
Then the resulting executable will sigsev on the line trying to assing 1.0 to f;
This affects all versions of clang 7-11 on a PC 64bit. I have managed to try a clang-12 on a mac as well, that was also affected.
It also works if you replace float with int.
I am puzzled now as this seems like a very obvious error. Is -mcmodel=large supported at all? Am I doing something wrong?
Thanks for your help