From mboxrd@z Thu Jan 1 00:00:00 1970
Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail
From: Philipp Stephani
Newsgroups: gmane.emacs.devel
Subject: Re: [Emacs-diffs] master 74f54af: Use eassume (false) for branch
that's never taken.
Date: Fri, 19 Apr 2019 21:14:52 +0200
Message-ID:
References: <83ftqecrms.fsf@gnu.org>
<83ef5ycnny.fsf@gnu.org>
<9b3a1717-64de-795a-2acf-0698576caf02@cs.ucla.edu>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226";
logging-data="82397"; mail-complaints-to="usenet@blaine.gmane.org"
Cc: Philipp Stephani , Eli Zaretskii ,
Emacs developers
To: Paul Eggert
Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Apr 19 21:16:47 2019
Return-path:
Envelope-to: ged-emacs-devel@m.gmane.org
Original-Received: from lists.gnu.org ([209.51.188.17])
by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256)
(Exim 4.89)
(envelope-from )
id 1hHZ0B-000LJj-3v
for ged-emacs-devel@m.gmane.org; Fri, 19 Apr 2019 21:16:47 +0200
Original-Received: from localhost ([127.0.0.1]:60317 helo=lists.gnu.org)
by lists.gnu.org with esmtp (Exim 4.71)
(envelope-from )
id 1hHZ0A-00087z-1s
for ged-emacs-devel@m.gmane.org; Fri, 19 Apr 2019 15:16:46 -0400
Original-Received: from eggs.gnu.org ([209.51.188.92]:58330)
by lists.gnu.org with esmtp (Exim 4.71)
(envelope-from ) id 1hHZ03-000873-Nx
for emacs-devel@gnu.org; Fri, 19 Apr 2019 15:16:40 -0400
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
(envelope-from ) id 1hHYyX-0007TU-LZ
for emacs-devel@gnu.org; Fri, 19 Apr 2019 15:15:06 -0400
Original-Received: from mail-ot1-x336.google.com ([2607:f8b0:4864:20::336]:38887)
by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
(Exim 4.71) (envelope-from )
id 1hHYyV-0007St-W0; Fri, 19 Apr 2019 15:15:04 -0400
Original-Received: by mail-ot1-x336.google.com with SMTP id e80so5057038ote.5;
Fri, 19 Apr 2019 12:15:03 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:cc; bh=yLZXKlcOP+ZRjJWNroFslIrAIov7eVR244mRgs2yFjI=;
b=jq16gQcjd0bNZX6eHpipUQGZLTJqwNT5qT245HE/Rknb6DM5RjsyENrhPNHDcz07LL
q/f34lW6M4I21rcQ8vvH+Hai/NszpAfK/xzF04ruhGqGK9OixUv4qdrOWCCy4NVez1Do
O6zKJ59mvqGFCTGJqQyxkUIb7kiS5zgkvCCpNIx0NdU3WwBnYRiepwuyEu/8yEfYOFZD
mUJxtejvT3jarxVixwo/SWlt5iDyA+CAta5EUmSeQZWPlMOTfvKR+4Cm8B+QhjYr5/9S
fMxL1+qY+wEXoS4LxJO8tQbFPGT7XMuDbgNzvgMG3nrgr6saybIVdJR+sd4X87icWgmA
acVg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc;
bh=yLZXKlcOP+ZRjJWNroFslIrAIov7eVR244mRgs2yFjI=;
b=sXgGOcoKFUD3fYcPV2axokSm43YJpi1g8iofDaTaa2cR9cXdeXLz/X8N66AnUNXZKn
rplAlxWuw30wPwc71jJMs4UQ6ice+O3FFeH8Fwosm+SgP/SLhOdRG88VzrHopHfCXpR+
9N0icNmnSVk0j/PMsKf3bVVUqskIqoUDw/BIzjnibSmNqtzaLX4cFx/RFVQ6RTOvbvdl
ZAmFxhrKm+LAS7vyTIbe8mY5bGYQerNsbKlX1lEJq64ROSvZyN++Hg8AxJkBDQ1OqYet
q9b6kwORoHjjlPpw2LhNPoHqVw6sYgXnz+9GTZfH32TF+H40bIxLU6SU15/ytPqbTNQ2
XOjw==
X-Gm-Message-State: APjAAAUSCnNo425NjqduvqEq1qHisVEj/FA570qaT0SII81OU0TygaNO
elRBTL9DB7/4l49R/TNqscWDZS8rhzY0XCG6wDg=
X-Google-Smtp-Source: APXvYqwvgukGSxX0Wdxhz55ztqBUP/ETWdzFcetmDrIgDNrLV08GtA2tj8Ry8TbY9KAHu625GPh0edZyyEq9eGutM20=
X-Received: by 2002:a05:6830:15d2:: with SMTP id
j18mr2985527otr.37.1555701303136;
Fri, 19 Apr 2019 12:15:03 -0700 (PDT)
In-Reply-To: <9b3a1717-64de-795a-2acf-0698576caf02@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
recognized.
X-Received-From: 2607:f8b0:4864:20::336
X-BeenThere: emacs-devel@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: "Emacs development discussions."
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org
Original-Sender: "Emacs-devel"
Xref: news.gmane.org gmane.emacs.devel:235668
Archived-At:
Am Fr., 19. Apr. 2019 um 21:04 Uhr schrieb Paul Eggert :
>
> On 4/19/19 3:08 AM, Eli Zaretskii wrote:
> > When ENABLE_CHECKING is not defined, which happens in every production
> > build, eassume expands to code that has no side effects, so the
> > function will return a random value to its caller. I don't think this
> > is desired.
>
> It looks OK to me. The default branch is impossible, so the function
> cannot return a random value to its caller. Although GCC is not smart
> enough to deduce this fact, eassume lets the programmer communicate it
> to GCC so that GCC doesn't issue a false-alarm diagnostic (and GCC also
> can generate better code). When ENABLE_CHECKING is defined, there's also
> a runtime check that the impossible does not happen, but this extra
> check isn't needed in ordinary production.
FWIW, I'm fine with both eassume(false) and emacs_abort.
>
> This would all be simpler if we replaced 'enum nonlocal_exit' with a
> simple boolean. The enum seems to be more trouble than it's worth, if
> it's causing this sort of bikeshedding. Not every boolean deserves an
> enum just for it.
>
I tend to disagree: In APIs, booleans should only be used for values
that have a clear false and true state (e.g. predicates). In other
cases booleans reduce readability (because "false" and "true" are
meaningless by themselves) and make extending unnecessarily hard.
I'm actually surprised that compilers warn about the lack of the
default case. The typical use for this construct is to signal that the
switch statement intends to handle all cases, causing a compiler
warning if new enumerators are added, which is very useful because it
reminds you of the callers that need to be adapted. Therefore it's
better to leave out the default case.