This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: nonnull, -Wnonnull, and do/while
- From: Marek Polacek <polacek at redhat dot com>
- To: stefan dot sobernig at wu dot ac dot at
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 16 Feb 2016 11:04:38 +0100
- Subject: Re: nonnull, -Wnonnull, and do/while
- Authentication-results: sourceware.org; auth=none
- References: <56C2EF2C dot 4050508 at thinkersfoot dot net>
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.
Marek