[Libreoffice] [PATCH] avoid ambiguous else

Kohei Yoshida kyoshida at novell.com
Wed Feb 2 11:38:21 PST 2011


On Thu, 2011-02-03 at 03:20 +0900, Takeshi Abe wrote:
> Hi,
> 
> On building calc, I found a warning suggesting an ambiguous "else".
> The attached patch is under LGPLv3+/MPL.

Hmm... But your patch may change the intention of that code block based
on how the lines are indented.

Here is the code we have right now

if(eType==SC_CAT_CONTENT)
    if(!pScChangeAction->IsDialogParent())
        pScChangeAction->GetDescription( aDesc, pDoc, TRUE);
else
    pScChangeAction->GetDescription( aDesc, pDoc,!pScChangeAction->IsMasterDelete());

which makes me think the the else block is supposed to get executed when

eType != SC_CAT_CONTENT

I have no idea how the compiler parses that block of code as it is
indeed ambiguous.  But I'm more in favor of interpreting it based on the
indent levels than how the compiler might be parsing it.

Kohei

-- 
Kohei Yoshida, LibreOffice hacker, Calc
<kyoshida at novell.com>




More information about the LibreOffice mailing list