[cfe-users] bug handling #line directive in clang?

Eran Talmor the.eran.talmor at gmail.com
Mon Jan 14 04:46:51 PST 2013


Hello,

I am observing a weird behavior in clang, inconsistent with gcc.
Consider the following file (bug.c):


extern int x;
int main()
{
#line 10 "foo.c"
  {
#line 100 "bug.c"
    int y=0;
  }
  ++x;
  return 0;
}


Obviously building it fails in the linking stage, as "x" is undefined.
That's fine.
The problem is that clang reports the "++x" coming from a wrong file.
I expected to see the report on "bug.c", line 102.
However, clang reports it on "foo.c", line 102.
i.e. in the last #line pragma (#line 100 "bug.c") it used the line
information "100", but ignored the file information "bug.c"

Here's the command line I used:

clang -g bug.c -o bug.out


And this is the output it produced:

/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/bin/ld:
Dwarf Error: Invalid or unhandled FORM value: 25.
/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/bin/ld:
Dwarf Error: Invalid or unhandled FORM value: 25.
/tmp/bug-4lmk6q.o: In function `main':
..../*foo.c:102*: undefined reference to `x'
..../*foo.c:102*: undefined reference to `x'
clang: error: linker command failed with exit code 1 (use -v to see
invocation)


I observed this on the on version 3.1, 3.2 and the latest code from the
trunk.
Any ideas?

Much thanks,
Eran
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20130114/4bb0b59f/attachment.html>


More information about the cfe-users mailing list