| Issue |
174340
|
| Summary |
Certain floating-point constants and flags cause nominally constant initializers to be executed at runtime
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
tpwrules
|
I have a program which needs constant static data tables to be constant-initialized so they are available for global constructors and external parsing of the binary. This turns out to break if all of the following are true:
* The initialization also involves an _expression_ which is not constexpr
* The flag `-ftrapping-math` is passed
* A double precision float literal which does not exactly equal a single precision value is used to initialize a float element
In this case, Clang decides to initialize the data tables with zero in the binary and fill them in at runtime, which is a problem.
I don't know if this is a bug, but it's unexpected and not something GCC does. I've prepared a godbolt example which demonstrates the problem and explains how to mitigate the problem by removing one of the above factors: https://godbolt.org/z/oT6Y88fjG . But I don't think we should have to apply any mitigation and there may be an issue in the compiler.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs