[cfe-dev] pascal string bug

Robert Purves listrp at gmail.com
Tue Mar 31 19:28:38 PDT 2009


This example shows clang stumbling over a pascal string constant with - 
fpascal-strings (and failing to emit a gcc-style warning without - 
fpascal-strings).

$ cat test.c
unsigned char * Foo( void )
{
   static unsigned char s[256] = "\pHello";
   return s;
}


GCC
$ gcc -c test.c -o test.o
test.c:3:33: warning: unknown escape sequence '\p'
$ gcc -c test.c -o test.o -fpascal-strings

CLANG
$ clang -c test.c -o test.o
$ clang -c test.c -o test.o -fpascal-strings
Assertion failed: (V && "DeclRefExpr not entered in LocalDeclMap?"),  
function EmitDeclRefLValue, file CGExpr.cpp, line 641.
0   clang-cc          0x00d2e172 main + 13491682
1   clang-cc          0x00d2e560 main + 13492688
2   libSystem.B.dylib 0x943c32bb _sigtramp + 43
3   libSystem.B.dylib 0xffffffff _sigtramp + 1807994223
4   libSystem.B.dylib 0x9443723a raise + 26
5   libSystem.B.dylib 0x94443679 abort + 73
6   libSystem.B.dylib 0x944383db __assert_rtn + 101
7   clang-cc          0x0007d2b3 main + 184099
...
26  clang-cc          0x00050239 _mh_execute_header + 324153
27  clang-cc          0x00050b75 main + 2021
28  clang-cc          0x00001836 _mh_execute_header + 2102
Stack dump:
0.	Program arguments: /Users/rp/llvm/Debug/bin/clang-cc -S -disable- 
free --relocation-model pic --disable-fp-elim --unwind-tables=0 -- 
fmath-errno=0 -mmacosx-version-min=10.5.6 -fpascal-strings -arch i386 - 
o /tmp/cc-YSUk5h.s -x c test.c
1.	<eof> parser at end of file
2.	test.c:1:17: LLVM IR generation of declaration 'Foo'
3.	test.c:2:1: LLVM IR generation of compound statement ('{}')

$ clang-cc -version
Low Level Virtual Machine (http://llvm.org/):
  llvm version 2.6svn
  DEBUG build with assertions.
  Built Mar 31 2009(21:31:16).

Robert P.




More information about the cfe-dev mailing list