all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: "as-is" rule
Date: Wed, 30 Nov 2011 14:09:51 -0500	[thread overview]
Message-ID: <jwvsjl5ph9w.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <837h2h5ysc.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 30 Nov 2011 19:02:27 +0200")

>> I think you've hit a bug in gcc in this case: "e1 || e2" should not
>> evaluate e2 if e1 evaluates to non-0.
> This is what I always knew: that `e1 || e2 || e3' are evaluated left
> to right.  But I understand the "as-is" rule relaxed that.

No, it did not (and yes Samuel, it's "as-if", not "as-is", sorry).

All the "as-if" rule says is that the assembly code may do anything it
likes as long as the result agrees with some interpretation of the
semantics.  There's a lot of noise around this, but in the end it's
mostly irrelevant, all it says is: don't presume what kind of assembly
will be generated from the source code.  All programming languages admit
the "as-if" rule and other than C none bother to mention it.  C is
special only because it has a "low-level" history and feel which makes
many people assume many things which the semantics does not guarantee
(e.g. ((x-1)+1) may be different from x if x is a pointer to the
beginning of an object, since x-1 is undefined (or was it
"unspecified"?) in this case).
But the C semantics really does guarantee that "e1 || e2" only evaluates
e2 if e1 evaluates to 0, so the "as-if" rule is not the problem.

>> xassert ((row->enabled_p && !row->mode_line_p)
>> ? verify_row_hash (row) : 1);
> If we are dealing with a compiler bug, how can we be sure this
> expression will not hit the same bug?

We can't.

> Anyway, I eventually removed the assertion altogether, so this is a
> moot point now.

Thanks,


        Stefan



  reply	other threads:[~2011-11-30 19:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-30 12:35 "as-is" rule Eli Zaretskii
2011-11-30 13:57 ` Andreas Schwab
2011-11-30 14:20 ` Stefan Monnier
2011-11-30 17:02   ` Eli Zaretskii
2011-11-30 19:09     ` Stefan Monnier [this message]
2011-11-30 18:44   ` Samuel Bronson

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvsjl5ph9w.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.