Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

#if 0?0?0:0:0

1 view
Skip to first unread message

Francois Grieu

unread,
Mar 30, 2010, 12:47:00 PM3/30/10
to
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

Eric Sosman

unread,
Mar 30, 2010, 1:30:19 PM3/30/10
to

Looks like ig.

--
Eric Sosman
eso...@ieee-dot-org.invalid

Sjouke Burry

unread,
Mar 30, 2010, 2:29:00 PM3/30/10
to
No it is a case of a TA.

Francois Grieu

unread,
Apr 6, 2010, 8:17:27 AM4/6/10
to
I wrote:
> 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/VisualStudio/feedback/details/546053/if-1-1-1-1-1-cause-error-fatal-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

0 new messages