Skip to content

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

@andrew-taylor

Description

@andrew-taylor
$ 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions