tech-kern archive

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

Re: NULL pointer arithmetic issues



On 08.03.2020 19:42, Mouse wrote:
>>> The correct fix is not to disable the null-pointer-check option but
>>> to remove the broken automatic non-null arguments in GCC.
> 
>> The C standard and current usage (GNU) disagrees here.
> 
> GNU is not some kind of arbiter of "current usage" (whatever _that_
> means).
> 
>> memcpy (along with a number of other functions) must not accept NULL
>> arguments and compiler can optimize the code based on these
>> assumptions.
> 
> Then such functions - or the language in which they are embedded - is
> not suitable for writing kernels.
> 

Theoretical C is not suitable for writing kernels and we need extensions
for the freestanding environment. We require at least assembly stubs.

> But, is it "must not accept null arguments" or is it "may do anything
> they like when presented with null arguments"?

Actually both.

>  But the answer is to fix the problem, not to
> twist the code into a pretzel to work around the compiler's refusal to
> be suitable for the job.
> 

We use -fno-delete-null-pointer-checks to disable these optimizations.

Attachment: signature.asc
Description: OpenPGP digital signature



Home | Main Index | Thread Index | Old Index