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

[bug] amazing preprocessor bug

210 views
Skip to first unread message

Markus F.X.J. Oberhumer

unread,
Aug 20, 2004, 3:24:28 AM8/20/04
to
Today's lesson: fun with the preprocessor

Please try to compile this simple 3-liner:

#if (4 >> 1 >> 1 != 1)
#error
#endif

--> fatal error C1012 !?

Now let's omit parentheses and try again:

#if 4 >> 1 >> 1 != 1
#error
#endif

--> warning C4067, and the #if computation is wrong !!

Same things happen if you use "<<" or mix them.

Finally it's interesting to note that this problem seems to be present
at least since MSC 6.0 (this is _MSC_VER == 600 back from 1990). And it
has been confirmed to persist in the latest VS 2005 betas :-)

Regards,
Markus F.X.J. Oberhumer
<mar...@oberhumer.com>

David Lowndes

unread,
Aug 21, 2004, 4:34:56 AM8/21/04
to
>Finally it's interesting to note that this problem seems to be present
>at least since MSC 6.0 (this is _MSC_VER == 600 back from 1990). And it
>has been confirmed to persist in the latest VS 2005 betas :-)

Have you filed a bug report on it for VS2005?

http://labs.msdn.microsoft.com/productfeedback/

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq

Carl Daniel [VC++ MVP]

unread,
Aug 21, 2004, 10:20:53 AM8/21/04
to
David Lowndes wrote:
>> Finally it's interesting to note that this problem seems to be
>> present at least since MSC 6.0 (this is _MSC_VER == 600 back from
>> 1990). And it has been confirmed to persist in the latest VS 2005
>> betas :-)
>
> Have you filed a bug report on it for VS2005?
>
> http://labs.msdn.microsoft.com/productfeedback/

I'd go ahead and file it, but I know that the VC team is aware the the
preprocessor has quite a number of conformance issues.

-cd


David Lowndes

unread,
Aug 23, 2004, 2:51:47 PM8/23/04
to
>Please try to compile this simple 3-liner:
>
>#if (4 >> 1 >> 1 != 1)
>#error
>#endif
>
>--> fatal error C1012 !?
>
>Now let's omit parentheses and try again:
>
>#if 4 >> 1 >> 1 != 1
>#error
>#endif
>
>--> warning C4067, and the #if computation is wrong !!
>
>Same things happen if you use "<<" or mix them.

The following seems OK with the 2005 beta:

#if (4 >> 1) >> 1 != 1

Is that a possible work-around for now?

David Lowndes

unread,
Aug 23, 2004, 3:04:55 PM8/23/04
to
0 new messages