[LLVMbugs] [Bug 4442] New: Format string modifier functions with format_arg attribute

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Jun 24 13:24:11 PDT 2009


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

           Summary: Format string modifier functions with format_arg
                    attribute
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: parser
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: tss at iki.fi
                CC: llvmbugs at cs.uiuc.edu


gcc has this nice feature where it (apparently) assumes that when a function is
of type

const char *function(const char *) __attribute__((format_arg(1)))

it assumes that the return value is also a format string. So for example gcc
gives a proper warning about the following code:

const char * __attribute__((format_arg(1)))
format(const char *format) { return format; }

int main(int argc, char **argv)
{
        printf(format("%s"), 1234); // warning
        printf(format("%s"), "str"); // no warning even with
-Wformat-nonliteral
        return 0;
}

Would be nice if clang did the same thing, or implemented some other way to
mark the return value as a format string.


-- 
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