[llvm-dev] float vs. mcmodel=large

Ákos Tompos via llvm-dev llvm-dev at lists.llvm.org
Mon Jan 4 02:51:27 PST 2021


Hi All,

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:

int main()
{
    float f = 1.0f;
    return 0;
}

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.
Clang-6.0 works.
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
Akos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210104/d25a2f36/attachment.html>


More information about the llvm-dev mailing list