tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Compiling kernel with -std=gnu11



> Date: Sun, 5 Jan 2025 17:03:23 +0000
> From: Taylor R Campbell <riastradh%NetBSD.org@localhost>
> 
> 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'.)

But since there's essentially no floating-point arithmetic in the
kernel, this is unlikely to matter for the kernel build.


Home | Main Index | Thread Index | Old Index