[LLVMbugs] [Bug 21082] New: __attribute__((__format__(printf ignored for function pointer members of struct

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Sep 26 10:05:56 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=21082

            Bug ID: 21082
           Summary: __attribute__((__format__(printf ignored for function
                    pointer members of struct
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: noselasd at fiane.mooo.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The following code

struct fmt_test {

    void (*func)(const char *fmt, ...) __attribute__((__format__(printf, 1,
2)));
};

void (*g_func)(const char *fmt, ...) __attribute__((__format__(printf, 1, 2)));
int main(int argc, char *argv[])
{
    struct fmt_test t;

    t.func("Hello %s");
    g_func("Hello %s");

    return 0;
}

produces 1 warning
$ clang    -Wall test.c 
test.c:12:20: warning: more '%' conversions than data arguments [-Wformat]
    g_func("Hello %s");
                  ~^
1 warning generated.

I'd expect it to produce the same warning for the line that reads

 t.func("Hello %s");


$ clang -v
clang version 3.4 (tags/RELEASE_34/final)
Target: x86_64-redhat-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.2
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.3
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.3

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140926/5daf6964/attachment.html>


More information about the llvm-bugs mailing list