[PATCH, C/C++] Add -fno-float to forbid floating point data types

Hans-Peter Nilsson hp@bitrange.com
Tue Aug 12 21:46:00 GMT 2014


On Tue, 12 Aug 2014, Thomas Preud'homme wrote:
> As mentioned in PR60070, there is many cases when a programmer want to ensure
> that a program does not use any floating point data type. Other cases to consider
> is when a target has several floating point ABI and user want to ensure his/her
> is compatible with all available floating point ABI.

For the latter, you're too strict, the ABI might not matter
until e.g. functions are inlined and about to be laid out or
"expanded".

> Adding such a check also  provides
> an opportunity to adapt the behavior of the compiler based on its result.

The cases I've run into involves a requirement that all
floating-point-operations (typically in code with lots of it)
are converted into integer operations possibly made constant,
e.g. by casting constant expressions possibly involving
builtins.  I don't think this use-case is covered by your
implementation (other than trivially forbidding it).

Also, people will likely find a need to constrain code at
compile-time when this option is in effect, so can you please
add a built-in CPP definition activated by -fno-float, for
example __GCC_NO_FLOAT__?

brgds, H-P



More information about the Gcc-patches mailing list