Apache OpenOffice (AOO) Bugzilla – Issue 96087
basic: ambiguous && || sequence
Last modified: 2013-02-24 21:01:03 UTC
X && Y || Z binds operator precedence-wise as (X && Y) || Z not X && (Y || Z) so I am a little suspicious about... in basic/source/sbx/sbxexec.cxx while( *p && rCharClass.isAlphaNumeric( *p ) || *p == '_' ) which really means... while( (*p && rCharClass.isAlphaNumeric( *p )) || *p == '_' ) while while( *p && (rCharClass.isAlphaNumeric( *p ) || *p == '_' )) seems the more likely desired meaning ? similarly while( refVar.Is() && *p == '.' || *p == '!' ) means while( (refVar.Is() && *p == '.') || *p == '!' ) while while( refVar.Is() && (*p == '.' || *p == '!') ) seems more the likely intent ? and finally in basic/source/comp/scanner.cxx while( *pLine && ( *pLine == ' ' ) || ( *pLine == '\t' ) || ( *pLine == '\f' ) ) means while( (*pLine && ( *pLine == ' ' )) || ( *pLine == '\t' ) || ( *pLine == '\f' ) ) but I suspect while( *pLine && (( *pLine == ' ' ) || ( *pLine == '\t' ) || ( *pLine == '\f' ) )) is what we want. Patch attached to change to what I *suspect* we might mean.
Created attachment 57868 [details] dodgy code
Andreas, please have a look ...
STARTED
-> OOo 3.1
This somehow confuses me. I wonder why this bug does not affect the functionality. I will try to understand this, otherwise I'll move it to 3.2 to be on the save side in the sense of "never touch a running system".
I had a closer look and interestingly this seems to make no difference, at least for two of the cases. The results of (X && Y) || Z and X && (Y || Z) only differ if X==false/Y==true/Z==true or X==false/Y==false/Z==true In the cases while( *p... and while( *pLine... this is not possible. If *p / *pLine is false, the char is 0, so it cannot be anything else. This is not so obvious for the while( refVar.Is() case, but the cri- tical cases require z==true -> *p=='!'. I've never seen this, so this probably is an exotic case. At least this explains why this hasn't caused any problems so far. Applied patch, FIXED
ab->tkr: Please verify in source code
Verified in source code
seen in DEV300_m45 and OOO310_m9