Date: Tue, 13 Sep 2016 22:10:24 +0200 From: Cedric Blancher <cedric.blancher@gmail.com> To: twilight <pipfstarrd@openmailbox.org> Cc: "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org> Subject: Re: What is the point in expression: !!var ? Message-ID: <CALXu0UcLaNgEyd_SLxSRDMDv6kjsDKpPDRc%2BHHJfyAv-YAmYkQ@mail.gmail.com> In-Reply-To: <7bf5cd37-6436-8cec-74e3-f0856bcc807c@openmailbox.org> References: <7bf5cd37-6436-8cec-74e3-f0856bcc807c@openmailbox.org>
next in thread | previous in thread | raw e-mail | index | archive | help
The point is to transform the value of a (any kind, like pointer) to a
Boolean value.
Ancient C trick, goes back to dmr
Ced
On 13 September 2016 at 21:54, twilight <pipfstarrd@openmailbox.org> wrote:
> Hello,
>
> I'm digging through FreeBSD cppcheck scan report with hope to catch some
> bugs.
>
> I've came along a line:
> c = cond(token, val, yylex(), noeval | !!a);
>
> What's the point in using !! twice? Can it be deleted?
> Here is the context:
>
> static arith_t cond(int token, union yystype *val, int op, int noeval)
> {
> arith_t a = or(token, val, op, noeval);
> arith_t b;
> arith_t c;
>
> if (last_token != ARITH_QMARK)
> return a;
>
> b = assignment(yylex(), noeval | !a);
>
> if (last_token != ARITH_COLON)
> yyerror("expecting ':'");
>
> token = yylex();
> *val = yylval;
>
> c = cond(token, val, yylex(), noeval | !!a);
>
> return a ? b : c;
> }
>
>
> --
> Cheers~
>
> PGP key fingerprint:
> 07B3 2177 3E27 BF41 DC65 CC95 BDA8 88F1 E9F9 CEEF
>
> You can retrieve my public key at pgp.mit.edu.
> _______________________________________________
> freebsd-hackers@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
--
Cedric Blancher <cedric.blancher@gmail.com>
[https://plus.google.com/u/0/+CedricBlancher/]
Institute Pasteur
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CALXu0UcLaNgEyd_SLxSRDMDv6kjsDKpPDRc%2BHHJfyAv-YAmYkQ>
