#if 0?0?0:0:0

F

Francois Grieu

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

cause:
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
#endif
int main(void){return 0?0?0:0:0;}


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

Francois Grieu
 
E

Eric Sosman

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

cause:
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
#endif
int main(void){return 0?0?0:0:0;}


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

Looks like ig.
 
F

Francois Grieu

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

cause:
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
#endif
int main(void){return 0?0?0:0:0;}


Did I hit a bug in this compiler's preprocessor?

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."

https://connect.microsoft.com/Visua...al-error-c1017-with-c-compiler-16-00-30128-01

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"
#endif

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



Francois Grieu
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top