Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

printf "%s\n" of a NULL value produces incorrect explanation #95

Open
andrew-taylor opened this issue Nov 22, 2023 · 0 comments
Open

printf "%s\n" of a NULL value produces incorrect explanation #95

andrew-taylor opened this issue Nov 22, 2023 · 0 comments

Comments

@andrew-taylor
Copy link
Collaborator

$ cat a.c
#include <stdio.h>

int main(void) {
	char *p = NULL;
	printf("%s\n", p);
}
$ dcc a.c
a.c: In function ‘main’:
a.c:5:9: warning: argument 1 null where non-null expected [-Wnonnull]
    5 |         printf("%s\n", p);
      |         ^~~~~~~~~~~~~~~~~
a.c:5:9: note: in a call to built-in function ‘__builtin_puts’
dcc explanation: you are passing a NULL value as argument 1 to 'printf'.
Argument 1 to 'printf' should never be NULL.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant