[cfe-dev] libclang in c99-to-c89: crash detected during parsing

i-love-spam i-love-spam at yandex.ru
Fri Apr 26 12:11:10 PDT 2013

There is a small app that translated c99 src code to c89 (mainly to be able to compile some projects written in c99 with MS compiler).

I've built clang (with vs2008) and used that project multiple times, however, with latest builds of clang it does not work anymore.
Some files suddenly now produce error like this one:

libclang: crash detected during parsing: {
  'source_filename' : 'check_closesocket.i'
  'command_line_args' : [],
  'unsaved_files' : [],
  'options' : 1,

The source code of the c99conv is here: https://github.com/libav/c99-to-c89/blob/master/convert.c
If I replace libclang.dll with the one from 21st October 2012 svn of clang/llvm then everything works fine.

here's the test file check_closesocket.c:

#include <winsock2.h>
long check_closesocket(void) { return (long) closesocket; }
int main(void) { return 0; }

First, I generate preprocessed file (from vs2008 or 2010 command prompt):
cl -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -Dsnprintf=avpriv_snprintf -D_snprintf=avpriv_snprintf -Dvsnprintf=avpriv_vsnprintf -nologo -D_USE_MATH_DEFINES -Dinline=__inline -FIstdlib.h -Dstrtoll=_strtoi64 -Oy -P check_closesocket.c

output is saved to check_closesocket.i

Then, if I run this command: 
c99conv  check_closesocket.i check_closesocket.o_converted.c
c99conv  -ms check_closesocket.i check_closesocket.o_converted.c

I get the libclang: crash detected during parsing

any idea where parser became unable to parse ms headers?

More information about the cfe-dev mailing list