Visual Studio expression containing a term named "by" cannot be evaluated in the watch window

Posted by Andrei Pana on Stack Overflow See other posts from Stack Overflow or by Andrei Pana
Published on 2011-01-10T17:05:17Z Indexed on 2011/01/10 17:53 UTC
Read the original article Hit count: 432

Consider my C++ code below:

int _tmain(int argc, _TCHAR* argv[])
{
    int by = 10;
    printf("%d\n", by);

    int bx = 20;
    printf("%d\n", (by + bx));

    return 0;
}

which works fine. The funny thing is with the "by" variable. If I try to add a watch for a simple expression that contains by, the result will be CXX0030: Error: expression cannot be evaluated.

For example, on a breakpoint on return 0, if I add the following watches I get the results mentioned:

by : 10
bx : 20
by + 5 : CXX0030: Error: expression cannot be evaluated
bx + 5 : 25
by + bx : CXX0030: Error: expression cannot be evaluated
(by) + bx : 30
by + (bx) : CXX0030: Error: expression cannot be evaluated
bx + (by) : CXX0014: Error: missing operrand

This happens on VS2010, VS2008 on multiple computers.

So, more out of curiosity, what is happening with "by"? Is it some kind of strange operator? Why doesn't bx get the same treatment?

(I've tried google on this but it is quite difficult to get some relevant hits with terms like "by")

© Stack Overflow or respective owner

Related posts about c++

Related posts about watch