Compiler crashes with large number of -D arguments

Discussion created by arsenm on Mar 31, 2012
Latest reply on Apr 2, 2012 by

I've run into a compiler crash when using long strings of defines for the compiler. It happens if I have a large number of -D arguments that do not have a space between the -D and the symbol. I thought to try this since a long time ago there was a bug in the Apple compiler where -DD_I_BEGIN_WITH_D would lose the leading D so only _I_BEGIN_WITH_D would be defined.


If I have at least 40 -D arguments, it crashes. If I start removing the space from some of them, it does not. I'm not quite sure what the relation is between the missing space and the number, but the problem start happening around 40 arguments and changes depending on whether the space is there or not for some of the arguments. The length of the definitions seems to not matter, only the number.


The code that ran into this worked a few months ago with previous releases. I have tested this on Linux x86_64 and Windows 7 64. This is with Catalyst 12.3 on both.




const char* sampleSrc = "#warning I compile\n";

    // crashes if I have 40 or more
const char* sampleFlags =
        "-D D1=1 -D D2=1 -D D3=1 -D D4=1 -D D5=1 -D D6=1 -D D7=0 -D D8=0 -D D9=0 -D D10=0 "
        "-D D11=0 -D D12=0 -D D13=0 -D D14=0 -D D15=0 -D D16=0 -D D17=0 -D D18=0 -D D19=0 -D D20=0 "
        "-D D21=0 -D D22=0 -D D23=0 -D D24=0 -D D25=0 -D D26=0 -D D27=0 -D D28=0 -D D29=0 -D D30=0 "
        "-D D31=0 -D D32=0 -D D33=0 -D D34=0 -D D35=0 -D D36=0 -D D37=0 -D D38=0 -D D39=0 -D D40=1";

// if I remove the space between the -D and the value, it works.
// It also seems to work if you remove it from a small number of them also
const char* sampleFlagsNoSpace = 
        "-DD1=1 -DD2=1 -DD3=1 -DD4=1 -DD5=1 -DD6=1 -DD7=0 -DD8=0 -DD9=0 -DD10=0 "
        "-DD11=0 -DD12=0 -DD13=0 -DD14=0 -DD15=0 -DD16=0 -DD17=0 -DD18=0 -DD19=0 -DD20=0 "
        "-DD21=0 -DD22=0 -DD23=0 -DD24=0 -DD25=0 -DD26=0 -DD27=0 -DD28=0 -DD29=0 -DD30=0 "
        "-DD31=0 -DD32=0 -DD33=0 -DD34=0 -DD35=0 -DD36=0 -DD37=0 -DD38=0 -DD39=0 -DD40=1";

clCreateProgramWithSource(context, 1, &sampleSrc, NULL, sampleFlags);
// crashes