You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since quite some time, some functions like strlen() are declared as only allowing non-null arguments (either explicitly, or if their prototype matches the _builtin version).
The library function should imho nevertheless check the argument, since it might be referenced by code compiled by older gcc versions. Since newer gcc complain about such checks,i've disabled the warning about this some time ago.
However, it seems that the check is nevertheless removed from the code.An example for strlen:
Isn't this an artificial problem? If the standard says "The strlen function computes the length of the string pointed to by s" it is pretty explicit -- NULL isn't a string, it is a (usually void) pointer. So IMHO gcc is correct enforcing it / optimising it out.
Since quite some time, some functions like strlen() are declared as only allowing non-null arguments (either explicitly, or if their prototype matches the _builtin version).
The library function should imho nevertheless check the argument, since it might be referenced by code compiled by older gcc versions. Since newer gcc complain about such checks,i've disabled the warning about this some time ago.
However, it seems that the check is nevertheless removed from the code.An example for strlen:
produces:
I can't see any check for NULL there. Any idea how to solve that?
BTW, gcc-4 also seems to remove the check, just does not emit any warning.
BTW2, that code above (produced by gcc 7 and above) doesn't look very optimal. The version produced by gcc4 looks like this:
That is actually quite close to how you would IMHO code it directly in assembler.
The text was updated successfully, but these errors were encountered: