From: Paul Eggert <eggert@cs.ucla.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: FACE_FROM_ID vs FACE_OPT_FROM_ID
Date: Fri, 24 Jun 2016 13:17:39 +0200 [thread overview]
Message-ID: <576D16D3.2000801@cs.ucla.edu> (raw)
In-Reply-To: <83ziqa29gd.fsf@gnu.org>
On 06/24/2016 12:00 PM, Eli Zaretskii wrote:
>> my reading of this:
>>
>> #ifndef ENABLE_CHECKING
>> # define eassert(cond) ((void) (false && (cond))) /* Check COND compiles. */
>>
>> is that when ENABLE_CHECKING is not defined, eassert does nothing
>> useful.
Yes, of course. eassert (X) should appear only in places where X must
be true, i.e., where Emacs is seriously broken if X is false. That's the
standard meaning for assertions.
Another way to put it is that in general the behavior of eassert (X) is
undefined if X is false.When (defined ENABLE_CHECKING &&
!suppress_checking), this undefined behavior happens to be a diagnostic
and core dump. Otherwise the undefined behavior is whatever the
underlying system does afterwards; when (!defined ENABLE_CHECKING) this
yields better performance overall in the usual and expected case where
Emacs is working properly.
It is not necessary to put eassert (X) every place where an expression X
must be true. It's helpful only when we reasonably suspect there might
be a bug in Emacs, and where platforms typically will not immediately
fail for other reasons when X is false. So, before a pointer dereference
*P it's not necessary to do eassert (P != NULL) since typical platforms
immediately dump core when dereferencing a null pointer anyway.
Conversely, before a subscript operation A[I] it can be helpful to
eassert (0 <= I && I < N), since typical platforms lack reliable
subscript checking.
next prev parent reply other threads:[~2016-06-24 11:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-23 20:03 FACE_FROM_ID vs FACE_OPT_FROM_ID Eli Zaretskii
2016-06-24 0:23 ` Paul Eggert
2016-06-24 8:49 ` Eli Zaretskii
2016-06-24 9:27 ` Paul Eggert
2016-06-24 9:57 ` Eli Zaretskii
2016-06-24 10:00 ` Eli Zaretskii
2016-06-24 11:17 ` Paul Eggert [this message]
2016-06-24 13:43 ` Eli Zaretskii
2016-06-24 21:34 ` Paul Eggert
2016-06-25 7:48 ` Eli Zaretskii
2016-06-25 21:34 ` Paul Eggert
2016-07-02 9:50 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=576D16D3.2000801@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).