#if 0?0?0:0:0

Discussion in 'C Programming' started by Francois Grieu, Mar 30, 2010.

  1. The following 4-lines source fragment test.c (fourth line empty)
    #if 0?0?0:0:0
    int main(void){return 0?0?0:0:0;}

    test.c(1) : fatal error C1017: invalid integer constant expression
    when compiled by cl.exe aka "Microsoft (R) 32-bit C/C++ Optimizing
    Compiler Version 15.00.30729.01 for 80x86".

    On the other hand this compile and runs fine.
    #if 0?(0?0:0):0
    int main(void){return 0?0?0:0:0;}

    Did I hit a but it this compiler's preprocessor?

    Francois Grieu
    Francois Grieu, Mar 30, 2010
    1. Advertisements

  2. Francois Grieu

    Eric Sosman Guest

    Looks like ig.
    Eric Sosman, Mar 30, 2010
    1. Advertisements

  3. Francois Grieu

    Sjouke Burry Guest

    No it is a case of a TA.
    Sjouke Burry, Mar 30, 2010
  4. The consensus is yes. I duly reported it. And the (representative of)
    the compiler vendor says: "We were able to reproduce this issue. But
    Unfortunately we will not fix this issue as it is not a common code and
    is not a high priority issue. Thanks for playing with our product."


    I should probably have reported the problem as:

    // return the smallest of x y z
    #define MIN3(x,y,z) ( (x)>(y) ? (y)>(z) ? (z) : (y) : (x) )

    #define ALPHA 5
    #define BETA 4
    #define GAMMA 6

    #if MIN3(ALPHA,BETA,GAMMA) < 2
    #error "check ALPHA BETA GAMMA"

    int main(void){return 0?0?0:0:0;}

    Francois Grieu
    Francois Grieu, Apr 6, 2010
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.