views:

22

answers:

2

Blob is defined as follows:

unsigned char* blob=new unsigned char[64];

We then try using the immediate window

blob+12
0x084F8854
    *blob+12: 0x75 'u'
blob+13
0x084F8855
    *blob+13: 0x11 ''
blob+14
0x084F8856
    *blob+14: 0x94 ''
blob+12,3
0x084F8854
    [0]: 0x75 'u'
    [1]: 0x0 ''
    [2]: 0x0 ''

Why doesn't blob+12,3 display the 3 values for blob 12? What is it doing instead?

A: 

The language is C++. He has defined an unsigned char array and watching the variable values using the immediate window. The array name is blob. I tried on VS2008, I verified with a char pointer. when you say blob+12,3.., it is converted to (blob+12)[0],(blob+12)[1],(blob+12)[2]..which is essentially same as blob+13,blob+14 and blob+15 and soon.

krissam
Works exactly as described on VS2005 in managed mode (but not in native mode). You can also put "blob+12,3" into the watch window and it will show zeros there too. Weird. May be a Visual Studio bug.
+1  A: 

More generally, "blob,20" works, but "blob+0,20" does not.

My best guess is it's a bug of managed expressions evaluator. If you look in MSDN, they go in length about how these things don't work and those things don't work. It could be that, in the twisted mind of the evaluator, blob+12 constitutes a 1-element array of type char, therefore elements beyond the first can't be displayed.