This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/67093] New: incorrect -Wnonnull text for execl family of functions
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 02 Aug 2015 00:07:17 +0000
- Subject: [Bug c/67093] New: incorrect -Wnonnull text for execl family of functions
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67093
Bug ID: 67093
Summary: incorrect -Wnonnull text for execl family of functions
Product: gcc
Version: 5.1.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
When the execl function is invoked with a null second argument, GCC issues two
warnings, one saying "null argument where non-null required" and another "not
enough variable arguments to fit a sentinel."
The text of the first warning is incorrect. POSIX doesn't require that arg0 be
non-null, it only suggests that it point to a filename string. C also doesn't
require that argv[0] be non-null. The text of the second warning is
misleading. However, since many programs assume that argv[0] is non-null, a
warning is helpful, but the text should be adjusted so as not to imply stronger
requirements than POSIX imposes on strictly conforming programs. For instance,
the wording could be changed to say "null argument where non-null usually
expected."
$ cat t.c && ~/bin/powerpc64/bin/gcc -Wall t.c && ./a.out
#include <assert.h>
#include <stdio.h>
#include <unistd.h>
int main (int argc, char *argv[])
{
if (0 < argc)
execl (argv [0], (void*)0);
printf ("argv[argc] = %s\n", argv [argc] ? argv [argc] : "null");
assert (0 == argv [argc]);
return 0;
}
t.c: In function âmainâ:
t.c:8:9: warning: null argument where non-null required (argument 2)
[-Wnonnull]
execl (argv [0], (void*)0);
^
t.c:8:9: warning: not enough variable arguments to fit a sentinel [-Wformat=]
argv[argc] = null