[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Any C++ on Alpha gfurus out there?



> Try this code :
> 
> const char * EV_UnixMenu::_getItemPath(AP_Menu_Id id) const
> {
>         for (UT_uint32 k=0; (k < m_nrActualFactoryItems); k++)
>         {
>                 _wd * wd = (_wd *)m_menuFactoryItems[k].callback_action;
>                 if (wd)
>                    if (wd->m_id==id)
>                         return m_menuFactoryItems[k].path;
>         }
> 
> There might be a problem in the order the if expression is evaluated : if wd is
> NULL and wd->m_id is evaluated first... Crash !

If this code works and the other doesn't you've found a compiler bug. && is 
supposed to evaluate left to right (lazily, so that it stops when it knows the 
outcome).

/Anders


-- 
 -- Of course I'm crazy, but that doesn't mean I'm wrong.
Anders Hammarquist                                  | iko@cd.chalmers.se
Not system administrator at DjungelData             | Hem: +46 31 47 69 27
Chalmers University of Technology, G|teborg, Sweden | Mob: +46 707 27 86 87




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []