This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: nonnull, -Wnonnull, and do/while

On Tue, Feb 16, 2016 at 11:04:38AM +0100, Marek Polacek wrote:
> On Tue, Feb 16, 2016 at 10:43:08AM +0100, Stefan Sobernig wrote:
> > Under a recent gcc 6 [*], we run into -Wnonnull warnings using the
> > nonnull attribute:
> Yes, this warning has been enhanced for GCC 6.
> > test.c: In function 'f':
> > test.c:16:14: warning: nonnull argument 's' compared to NULL [-Wnonnull]
> >    } while (s != NULL);
> > 
> > Am I missing sth.? Is this a false positive?
> Well, it's just that "s" has the nonnull attribute so the compiler thinks it
> should never be null in which case comparing it to null should be redundant.
> Doesn't seem like a false positive to me, but maybe someone else feels
> otherwise.

The nonnull attribute should be solely about the value that is passed to the
function, it doesn't tell anything about the value of the argument after
it is changed.  So IMHO this warning change should be reverted and instead
we should warn somewhere soon after going into SSA, only when
the SSA_NAME_IS_DEFAULT_DEF of the PARM_DECL which has non-NULL attribute
is compared to NULL.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]