[Bug middle-end/17308] nonnull attribute not as useful as it could

msebor at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Feb 15 20:51:00 GMT 2010



------- Comment #5 from msebor at gmail dot com  2010-02-15 20:51 -------
I second Ulrich's request.

Besides nonnull, this enhancement would be useful in attribute printf
as well. For example, in the program below, both calls to printf() have
undefined behavior in C99 and should be diagnosed:

$ cat t.c && gcc -Wformat -pedantic -std=c99 -O3 t.c
int printf(const char*, ...)
  __attribute__((__nonnull__((1))))
  __attribute__ ((__format__ (__printf__, 1, 2)));

int main() {
  char *s = 0;
  printf(s, "");
  printf("%s", s);
}
$


-- 

msebor at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17308



More information about the Gcc-bugs mailing list