Re: Compiling kernel with -std=gnu11

Anders Magnusson <[email protected]>
Newsgroups gmane.os.netbsd.devel.kernel
Message-ID <[email protected]>
Den 2025-01-05 kl. 18:44, skrev Taylor R Campbell:
>> Date: Sun, 5 Jan 2025 17:03:23 +0000
>> From: Taylor R Campbell<[email protected]>
>>
>> I skimmed through
>> https://gcc.gnu.org/onlinedocs/gcc-10.5.0/gcc/C-Extensions.html
>> for other things whose semantics might change with -std=gnu11 vs
>> -std=c11, and the only case I came up with was the `\e' escape in
>> strings, of which we have one use: [...]
> I should note that I do know of at least one other semantic difference
> between -std=gnu11 and -std=c11 which may be significant even though
> it doesn't affect whether something builds or not:
>
> float
> foo(float x, float y, float c)
> {
> 	float p = x*y;
>
> 	return p + c;
> }
>
> Under -std=c11, this rounds the product to float precision first, and
> then computes the sum, as required by the C spec.  Under -std=gnu11,
> this may compute everything in double or extended precision, just like
> if it had been `return x*y + c' with no intermediate `float' variable
> assignment.  (The finer-grained option here is -fexcess-precision:
> under -std=c11 it's set to `standard'; under -std=gnu11, to `fast'.)
Hm, interesting optimization.  I understand why they have done this,
but I would not have expected it to be the default behaviour.
Writing code like this is not uncommon to get rounding as expected.

-- Ragge
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.