all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Strangeness in ASRT
@ 2008-02-10 18:42 Richard Stallman
  2008-02-10 19:38 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Stallman @ 2008-02-10 18:42 UTC (permalink / raw)
  To: emacs-devel

This seems to have a bug which breaks compilation.

    /* The IDX==IDX tries to detect when the macro argument is side-effecting.  */
    #define ASET(ARRAY, IDX, VAL)	\
      (eassert ((IDX) == (IDX)),				\
       eassert ((IDX) >= 0 && (IDX) < ASIZE (ARRAY)),	\
       ASLOT ((ARRAY), (IDX)) = (VAL))

Changing ASLOT to AREF makes it compile.  (Bootstrapping still crashes
as before.)

What is the purpose of these tests?  The expansion of AREF
substitutes IDX only once, so there is no problem if it has
a side effect.




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Strangeness in ASRT
  2008-02-10 18:42 Strangeness in ASRT Richard Stallman
@ 2008-02-10 19:38 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2008-02-10 19:38 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

> This seems to have a bug which breaks compilation.
>     /* The IDX==IDX tries to detect when the macro argument is side-effecting.  */
>     #define ASET(ARRAY, IDX, VAL)	\
>       (eassert ((IDX) == (IDX)),				\
>        eassert ((IDX) >= 0 && (IDX) < ASIZE (ARRAY)),	\
>        ASLOT ((ARRAY), (IDX)) = (VAL))

> Changing ASLOT to AREF makes it compile.  (Bootstrapping still crashes
> as before.)

Oh, yes, it should be AREF, not ASLOT.  Sorry for the mixup.

> What is the purpose of these tests?  The expansion of AREF
> substitutes IDX only once, so there is no problem if it has
> a side effect.

If ENABLE_CHECKING is true, then eassert ((IDX) >= 0 && (IDX) < ASIZE
(ARRAY)) will cause IDX to be eval'd several times, so you'll get errors
when you set ENABLE_CHECKING and an argument has the form "index++".


        Stefan




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-02-10 19:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-10 18:42 Strangeness in ASRT Richard Stallman
2008-02-10 19:38 ` Stefan Monnier

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.