all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
Subject: Re: Emacs port to gcc -fcheck-pointer-bounds
Date: Wed, 13 Dec 2017 11:39:53 -0800	[thread overview]
Message-ID: <90e8ba59-bbff-b1fb-9a99-c4426fa8d2ac@cs.ucla.edu> (raw)
In-Reply-To: <jwvmv2mv3si.fsf-monnier+gmane.emacs.devel@gnu.org>

On 12/13/2017 11:17 AM, Stefan Monnier wrote:
>> The fake pointer catches (at compile-time) common faults like the one 
>> the
>> attached patch fixes, where an int was passed where a Lisp_Object was 
>> expected. These are the most important faults that 
>> --enable-check-lisp-object-type catches. 
> ... it doesn't catch things like `x + n` since adding a constant to a 
> pointer is also a valid operation

Actually it catches even (x + n), because Lisp_Object is 'union Lisp_X 
*', and the union type is deliberately incomplete so the C compiler does 
not know its size and cannot multiply n by sizeof (union Lisp_X). The C 
Standard requires a diagnostic for (x + n) and practice compilers 
invariably issue at least a warning.

There are some things it doesn't catch. Most of these (e.g., 
'Lisp_Object x = 0;', or 'Lisp Object x = FOO, y = BAR; return x == y;') 
are harmless annoyances. The only worrisome thing not caught is 
converting between void * and Lisp_Object, e.g., 'Lisp_Object z = malloc 
(n);'. However, to my mind it's overkill to 
--enable-check-lisp-object-type by default just to catch this, as void * 
is dangerous with every C pointer type and there's little extra harm to 
making it dangerous with Lisp_Object too.

> Maybe we can turn it into a no-op.

Yes, that's my thought too.



  reply	other threads:[~2017-12-13 19:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-07  7:34 Emacs port to gcc -fcheck-pointer-bounds Paul Eggert
2017-12-08 13:45 ` Eli Zaretskii
2017-12-08 22:06   ` Paul Eggert
2017-12-09  8:33     ` Eli Zaretskii
2017-12-10  7:10       ` Paul Eggert
2017-12-10 17:27         ` Eli Zaretskii
2017-12-11  7:54           ` Paul Eggert
2017-12-11 15:26             ` Eli Zaretskii
2017-12-12 23:35               ` Paul Eggert
2017-12-13 16:20                 ` Eli Zaretskii
2017-12-13 18:30                   ` Paul Eggert
2017-12-13 19:17                     ` Stefan Monnier
2017-12-13 19:39                       ` Paul Eggert [this message]
2017-12-18  2:47                       ` Paul Eggert
2017-12-08 16:13 ` Pip Cet
2017-12-08 22:09   ` Paul Eggert

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=90e8ba59-bbff-b1fb-9a99-c4426fa8d2ac@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.