-Wformat-diag: floating-point or floating point?

Martin Sebor msebor@gmail.com
Wed May 22 14:58:00 GMT 2019

On 5/22/19 6:27 AM, Richard Earnshaw (lists) wrote:
> On 22/05/2019 13:17, Bill Schmidt wrote:
>> On 5/22/19 5:19 AM, Richard Earnshaw (lists) wrote:
>>> On 21/05/2019 21:18, Bill Schmidt wrote:
>>>> On 5/21/19 11:47 AM, Martin Sebor wrote:
>>>>> The GCC coding style says to use "floating-point" as an adjective
>>>>> rather than "floating point."  After enhancing the -Wformat-diag
>>>>> checker to detect this I found a bunch of uses of the latter, such
>>>>> as in:
>>>>>    gcc/c/c-decl.c:10944
>>>>>    gcc/c/c-parser.c:9423, 9446, 9450, etc.
>>>>>    gcc/convert.c:418, 422
>>>>>    gcc/cp/call.c:5070
>>>>>    gcc/cp/cvt.c:886
>>>>> Before I fix them all and adjust the tests, I want to make sure
>>>>> we really want to follow this rule.  The C standard uses both
>>>>> interchangeably.  With just one exception, the C++ standard uses
>>>>> the hyphenated form.
>>>> The hyphenated form is correct English, so I certainly prefer it. :-)
>>> It's not quite as simple as that.  Hyphens should be used to make it
>>> clear what is the adjective and what is the noun:
>>>     A floating-point number (hyphenated) is a number with a
>>>     floating point (no hyphen).
>>> In the first case 'floating-point' is the adjective and qualifies
>>> number.  In the second case 'floating' is the adjective and qualifies
>>> 'point'.
>>> But this is English, so there are probably some exceptions even then -
>>> but not in this case, I think.  :-)
>> English is always fun, agreed -- Martin cited the requirement to use
>> "floating-point" when it's used as an adjective, which is certainly correct.
>> There's a more interesting question around cavalier usage such as,
>> "We should use floating point."  I would argue that there is an implied
>> noun "arithmetic" modified here, so this should also be hyphenated,
>> but I daresay there would be people on both sides of this one...
> I would argue that leaving out "arithmetic" is the error. :-)

I agree.  Unfortunately, there are a few cases like that among
the diagnostics that my script has already fixed:

   decimal floating point not supported
   comparing floating point with %<==%> or %<!=%> is unsafe
   ISO C does not support decimal floating point

They probably should read

   decimal floating point types not supported
   comparing floating-point values with %<==%> or %<!=%> is unsafe
   ISO C does not support decimal floating point types

I think they can be adjusted later if we think it's important,
after the checker is finalized and committed.  I don't want to
complicate it too much by having to differentiate between
adjectives and nouns.  The vast majority of the "floating point"
instances is has found are adjectives.


>> This is why grammar police usually die from friendly fire. :-)
> Sticking your head above the parapet is always fraught with danger :)
> R.

More information about the Gcc mailing list