[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lparser.c:singlevar() asserts potentially uninitialised value.
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 5 May 2016 11:04:53 -0300
> > We cannot put the call inside the assert, so we need to assign
> > the return to a variable and assert on that variable. But without
> > assertions, we get a "unused variable" warning (and a weird code). Then
> > we add a "(void)var" to avoid the warning, and get weirder code. All in
> > all, the current assertion documents what we want and keeps the regular
> > code simple. (After all, if the assertion holds, its code is correct ;-)
>
> You're claiming the converse of the assertion, not the contrapositive.
Of course I am. The ";-)" in that message has a meaning...
> [...] What is wrong a construction like:
>
> ```c
> if (VVOID == singlevaraux()) {
> lua_assert(0 && "Error Message");
> }
> ```
It is (very) weird :-) It adds code outside an assertion only to make an
assertion. Some compiler could (with reason) give a warning about
these useless (and weird) comparison/test when assertions are off.
-- Roberto