Missing warning about missing alert for exec in C ++ 11

GCC will help you warn you if you forget to turn on the NULL watch at the end of a call to one of the exec (3) functions

#include <unistd.h>
int main(int argc, char **argv)
{
  execlp("test", "test", "arg1");
}

Example compiler output for GCC 4.8:

$ g++ test.cc -Wformat
test.cc: In function ‘int main(int, char**)’:
test.cc:4:32: warning: missing sentinel in function call [-Wformat=]
   execlp("test", "test", "arg1");
                            ^
$

However, if you compile in C ++ 11 mode, the diagnostics will not print:

$ g++ test.cc -std=c++11 -Wformat
$

Why is this warning not available in C ++ 11? Is there any way to get it back?

+4
source share
1 answer

execlp C. "" , , , -std=gnu++11 -std=c++11. , -std=gnu++98. Glibc , sentinel execlp.

+4

All Articles