Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: How to avoid an overflow during multiplication? Date: Mon, 07 Feb 2022 09:06:23 -0800 Organization: A noiseless patient Spider Lines: 24 Message-ID: <86pmnyip2o.fsf@linuxsc.com> References: <877dbk36qu.fsf@nosuchdomain.example.com> <86v8ydp57h.fsf@linuxsc.com> <86pmojo7th.fsf@linuxsc.com> <86sfszlsfd.fsf@linuxsc.com> <6f966456-55d7-40f4-9815-25096cd2c709n@googlegroups.com> <867da7jbxc.fsf@linuxsc.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="792c2a82c28252afd7e8a94f82466189"; logging-data="18554"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ZWfrhilPTqXh77eoniYgkAUVcBo9MDzM=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:aJE1ToUx1q1D0zjvPBOmWo+mF9w= sha1:N1czkz7nwL9dJMJaZjPgVda4Kv8= Xref: csiph.com comp.lang.c:164855 Bart writes: > On 07/02/2022 08:52, Tim Rentsch wrote: > >> Using _Bool works here too: >> >> _Bool p_valid = p; >> >> The conversion to _Bool converts null pointers to 0, and non-null >> pointers to 1. > > This leads to: > > _Bool b; > > b = &b; > > which looks unintuitive. Usually the LHS would be of type T, then the > RHS would have the incompatible type T* It is querelis gratia querimonia as usual, I see. (With apologies to my high school Latin teacher. I never was good at Latin.)