Fix macroexp crash on Windows with debugging.
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 2 Aug 2012 20:59:49 +0000 (13:59 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 2 Aug 2012 20:59:49 +0000 (13:59 -0700)
* lisp.h (ASET) [ENABLE_CHECKING]: Ignore ARRAY_MARK_FLAG when
checking subscripts; problem introduced with the recent
"ASET (a, i, v)" rather than "AREF (a, i) = v" patch.
(ARRAY_MARK_FLAG): Now a macro as well as a constant,
since it's used in non-static inline functions now.

Fixes: debbugs:12118

src/ChangeLog
src/lisp.h

index c590e9f..45b2443 100644 (file)
@@ -1,5 +1,12 @@
 2012-08-02  Paul Eggert  <eggert@cs.ucla.edu>
 
+       Fix macroexp crash on Windows with debugging (Bug#12118).
+       * lisp.h (ASET) [ENABLE_CHECKING]: Ignore ARRAY_MARK_FLAG when
+       checking subscripts; problem introduced with the recent
+       "ASET (a, i, v)" rather than "AREF (a, i) = v" patch.
+       (ARRAY_MARK_FLAG): Now a macro as well as a constant,
+       since it's used in non-static inline functions now.
+
        * xfaces.c (face_at_buffer_position, face_for_overlay_string):
        Don't assume buffer size fits in 'int'.  Remove unused local.
 
index 4b54af9..3d00f4d 100644 (file)
@@ -331,7 +331,9 @@ enum CHECK_LISP_OBJECT_TYPE { CHECK_LISP_OBJECT_TYPE = 0 };
 
 /* In the size word of a vector, this bit means the vector has been marked.  */
 
-static ptrdiff_t const ARRAY_MARK_FLAG = PTRDIFF_MIN;
+static ptrdiff_t const ARRAY_MARK_FLAG
+#define ARRAY_MARK_FLAG PTRDIFF_MIN
+      = ARRAY_MARK_FLAG;
 
 /* In the size word of a struct Lisp_Vector, this bit means it's really
    some other vector-like object.  */
@@ -606,7 +608,7 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper)
 /* 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)),      \
+   eassert ((IDX) >= 0 && (IDX) < (ASIZE (ARRAY) & ~ARRAY_MARK_FLAG)), \
    XVECTOR (ARRAY)->contents[IDX] = (VAL))
 
 /* Convenience macros for dealing with Lisp strings.  */