[LLVMbugs] [Bug 4991] New: __TIMESTAMP__ has trailing newline

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Sep 16 01:10:23 PDT 2009


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

           Summary: __TIMESTAMP__ has trailing newline
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: preprocessor
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: edwintorok at gmail.com
                CC: llvmbugs at cs.uiuc.edu


__TIMESTAMP__ has a trailing newline on Linux/x86-64 (that is what
ctime/ctime_r returns), which causes invalid C code to be generated (clang
accepts it though).

Compiling this code with clang outputs a trailing newline:
#include <stdio.h>
int main()
{
    puts(__TIMESTAMP__);
}

Compiling it like this works:
$ clang foo.c && ./a.out
Wed Sep 16 11:08:01 2009

$

However if I preprocess first, clang doesn't accept its own (!) preprocessed
output:
clang -E foo.c|clang -x c -
In file included from foo.c:1:
In file included from foo.c:1:
foo.c:4:10: error: missing terminating '"' character
    puts("Wed Sep 16 11:08:01 2009
         ^
foo.c:4:10: error: expected expression
foo.c:5:1: error: missing terminating '"' character
");
^
foo.c:6:2: error: expected '}'
}
 ^
4 diagnostics generated.


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