询问者
B2CSE.exe在转换诸如Set Screen=doc.parentWindow.screen时存在BUG

问题
-
dim screen as object
dim doc as object
Set Screen=doc.parentWindow.screenint level=0; // Current index into root[] // Line 3: Set Screen = doc . parentWindow . screen VariantCopy(&root[++level], &doc); AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &root[level+1], root[level++].pdispVal, L"parentWindow", 0); AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &rVal, root[level].pdispVal, L"screen", 0); VariantClear(&root[level--]); VariantClear(&root[level--]); VariantCopy(&Screen, &rVal); VariantClear(&rVal);
在第一个AutoWrap中&root[level+1]的level是多少?其实不可知的。
如果根据C++参数传入右->左,排除优化过程,那么先计算root[level++].pdispVal传入,level原来是1,因此,传入root[1].pdispVal,并且level=2
然后传入&root[level+1],因此传入&root[3],也就是Autowarp的结果放在doc.parentWindow对象放在root[3]中
那么第二个AutoWarp就出问题了,传入的root[level].pdispVal是level=2,root[2]是空的,所以,第二个Autowrap报错。
在VS2008(无sp1补丁)+Win7 64位下验证了上面的推测,结果放在root[3]中,root[2]空,Autowrap报错。
并且根据C99中提到了
The order of evaluation of the function designator, the actual arguments, and subexpressions within the actual arguments is unspecified, but there is a sequence point before the actual call.
EXAMPLE In the function call (*pf[f1()]) (f2(), f3() + f4()) the functions f1, f2, f3, and f4 may be called in any order. All side effects have to be completed before the function pointed to by pf[f1()] is called.
传入参数的表达式计算顺序是不确定的,不建议使用这一的表达方式。
同样在B2CSE.exe的样例中Excel97也有这一的错误代码
// Line 27: app . activeworkbook . saved = 1 rVal.vt = VT_I4; rVal.lVal = 1; VariantCopy(&root[++level], &app); AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &root[level+1], root[level++].pdispVal, L"activeworkbook", 0); AutoWrap(DISPATCH_PROPERTYPUT, NULL, root[level].pdispVal, L"saved", 1, rVal); VariantClear(&root[level--]); VariantClear(&root[level--]); VariantClear(&rVal);
第一个AutoWrap的root[level+1]到底是第几个元素不可知,不同编译器有不同结果
全部回复
-
你好,
鉴于您的问题, 我建议您可以到以下地址提出您的问题: http://answers.microsoft.com/en-us
Rob Pan [MSFT]
MSDN Community Support | Feedback to us
-
这个应该算是bug反馈,我不知道去哪里反馈,显然你给我的地址不对,http://answers.microsoft.com/en-us 那里是咨询的,这个问题都没法在那里归类,windows?ie?office?还是security?
-
你好,
如果您需要提供 反馈意见,您可以到以下地址: http://connect.microsoft.com/
Rob Pan [MSFT]
MSDN Community Support | Feedback to us