[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: modifying pointers

From: Ludovic Courtès
Subject: Re: modifying pointers
Date: Fri, 09 Apr 2010 18:30:07 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)


Andy Wingo <address@hidden> writes:

> You added a change to foreign-set! for %null-pointer. Would it not make
> sense instead to make foreign pointers of type "void" unsettable?

Not necessarily.  See the test that was added:

--8<---------------cut here---------------start------------->8---
  (pass-if "foreign-set! other-null-pointer"
    (let ((f (bytevector->foreign (make-bytevector 2))))
      (and (not (= 0 (foreign-ref f)))
             (foreign-set! f 0)
             (= 0 (foreign-ref f)))
             ;; Here changing the pointer value of F is perfectly valid.
             (foreign-set! f 777)
             (= 777 (foreign-ref f))))))
--8<---------------cut here---------------end--------------->8---

Here a ((void *) 777) pointer is created.

However, this is not allowed for ‘%null-pointer’ because (1) that would
change its semantics, and (2) it’s defined as ‘const’ anyway, so
modifying it leads to a segfault.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]