[LLVMbugs] [Bug 15114] New: Format attribute should not require variadic function

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jan 29 12:33:00 PST 2013


             Bug #: 15114
           Summary: Format attribute should not require variadic function
           Product: clang
           Version: 3.2
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: msharov at users.sourceforge.net
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

clang makes it impossible to write a template printf wrapper without a warning:

template <typename... T>
inline void LogError (const char* fmt, T... args)
{ printf (fmt, args...); }

Produces the -Wformat-security error, "fmt is not a string literal". With gcc
it is possible to declare such a function with
__attribute__((__format__(printf,1,2))). clang complains that this attribute
requires a variadic function. Using (printf,1,0) is allowed, but still produces
the security error.

This example uses a variadic template, but simple wrappers with a fixed number
of arguments should also be possible to tag with the format attribute.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list