[Interest] How does one use Q_ASSUME?
Thiago Macieira
thiago.macieira at intel.com
Tue May 28 20:35:13 CEST 2019
On Sunday, 26 May 2019 08:55:33 PDT Elvis Stansvik wrote:
> > 2) unlike the other compilers, the conditional is actually in evaluated
> > context. So make sure you only Q_ASSUME on variables, never on function
> > calls. GCC will call them, the others won't. This is the same rule as
> > Q_ASSERT, btw.
> The way Q_ASSUME is defined, isn't that true for non-GCC too?
>
> #define Q_ASSUME(Expr) \
> do {\
> const bool valueOfExpression = Expr;\
> Q_ASSERT_X(valueOfExpression, "Q_ASSUME()", "Assumption in
> Q_ASSUME(\"" #Expr "\") was not correct");\
> Q_ASSUME_IMPL(valueOfExpression);\
> } while (false)
>
> Won't Expr be evaluated at the const bool valueOfExpression = Expr; ?
Oops, that's true. I didn't remember we had changed it; my original goal was
different.
Thanks for pointing it out.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel System Software Products
More information about the Interest
mailing list