[LLVMbugs] [Bug 14570] New: Clang "expanded from here/macro" outputs garbage characters (<U+0000><U+000A>)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Dec 11 04:07:34 PST 2012


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

             Bug #: 14570
           Summary: Clang "expanded from here/macro" outputs garbage
                    characters (<U+0000><U+000A>)
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: matti.niemenmaa+llvmbugs at iki.fi
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 9673
  --> http://llvm.org/bugs/attachment.cgi?id=9673
Testcase affecting r169381

Akin to #12674, but still happens with trunk (r169381).

The full test case is attached. It consists of the following five lines
followed by 671 blank lines; removing any line hides the issue.

#define CAT(a,b) a##b
#define UNDEF CAT(foo, bar)
#include <assert.h>
#include <limits.h>
UNDEF x1; UNDEF x2; UNDEF x3;

Unfortunately it does depend on those specific #includes, which might make
reproducing this quite environment-dependent. (The machine I see this on is an
x86-64 running Arch Linux, with glibc 2.16.0 and gcc 4.7.2.) I haven't figured
out a way to see this issue without those #includes.

In general this appears to be quite fragile: the testcase doesn't affect 3.1 or
3.2, only trunk, but both 3.2 and trunk have the same garbage output on the
(big) case I actually ran into. (And 3.1 is of course affected by #12674.)

I will try to bisect Clang to find the cause, and maybe find a better testcase
on the way.

$ clang -fsyntax-only x.cpp
x.cpp:5:1: error: unknown type name 'foobar'
UNDEF x1; UNDEF x2; UNDEF x3;
^
x.cpp:2:15: note: expanded from macro 'UNDEF'
#define UNDEF CAT(foo, bar)
              ^
x.cpp:1:18: note: expanded from macro 'CAT'
#define CAT(a,b) a##b
                 ^
<scratch space>:3:1: note: expanded from here
foobar
^
x.cpp:5:11: error: unknown type name 'foobar'
UNDEF x1; UNDEF x2; UNDEF x3;
          ^
x.cpp:2:15: note: expanded from macro 'UNDEF'
#define UNDEF CAT(foo, bar)
              ^
x.cpp:1:18: note: expanded from macro 'CAT'
#define CAT(a,b) a##b
                 ^
<scratch space>:3:9: note: expanded from here
foobar<U+0000><U+000A>foobar
                      ^
x.cpp:5:21: error: unknown type name 'foobar'
UNDEF x1; UNDEF x2; UNDEF x3;
                    ^
x.cpp:2:15: note: expanded from macro 'UNDEF'
#define UNDEF CAT(foo, bar)
              ^
x.cpp:1:18: note: expanded from macro 'CAT'
#define CAT(a,b) a##b
                 ^
<scratch space>:3:17: note: expanded from here
foobar<U+0000><U+000A>foobar<U+0000><U+000A>foobar
                                            ^
3 errors 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