https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108893

--- Comment #8 from Jonny Grant <jg at jguk dot org> ---
(In reply to Andrew Pinski from comment #7)
> access attribute says if it is access, then it will be that. It does not say
> it MUST be accessed. That is what nonnull is for.
> 
> >I didn't want to use __attribute__((nonnull)) because the optimizer may use 
> >that knowledge to remove nullptr checks. 
> 
> It only uses it afterwards or inside the function.
> It cannot use nonnull attribute to optimize before the access has happened.

Thank you for your reply.

https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html

The manual does state:

quote 1:
"The compiler may also perform optimizations based on the knowledge that
certain function arguments cannot be null. These optimizations can be disabled
by the -fno-delete-null-pointer-checks option. See Optimize Options."

quote 2:
"The compiler may also perform optimizations based on the knowledge that nonnul
parameters cannot be null. This can currently not be disabled other than by
removing the nonnull attribute."

So the caveat is this issue (2). I can't use attribute nonnull due to these
optimizations that cannot be disabled.

BTW, there is a "nonnul" typo there, if you have a moment and commit access to
change (the patches I sent to gcc-patches for documentation didn't get any
replies)

Thank you again for your reply.

Reply via email to