Skip to content

__attribute__((__format__(printf()))) doesn't warn about NULL format string #33923

@llvmbot

Description

@llvmbot
Bugzilla Link 34575
Version 5.0
OS All
Reporter LLVM Bugzilla Contributor

Extended Description

Take this code:

#include <stdio.h>

int main()
{
  printf(NULL, "x");
  return 0;
}

gcc helpfully warns that:

<source>: In function 'int main()':
5 : <source>:5:19: warning: null argument where non-null required (argument 1) [-Wnonnull]
   printf(NULL, "x");
               ^
5 : <source>:5:19: warning: too many arguments for format [-Wformat-extra-args]

while clang doesn't say anything (it doesn't even warn about extra arguments). It would be nice if it did.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions