clang complaints

Stephen J. Turnbull stephen at xemacs.org
Thu Oct 20 12:43:11 EDT 2011


Hi all,

I've recently started building with clang, which indeed does give
nicer error messages than GCC (at least up to GCC v4.4).  However, it
also gives an annoying warning about the extensible struct idiom:

struct Lisp_Vector {
  NORMAL_LISP_OBJECT_HEADER header;
  long size;
  Lisp_Object contents[1];
}

where we allocate a larger buffer to hold our Lisp_Vector, then
populate contents[] with more objects than it is declared to hold.
Like this:

------------------------------------------------------------------------------
/playpen/src/XEmacs/xemacs/src/frame.c:2903:28: warning: array index of '1' indexes past the end of an array (that contains 1 elements) [-Warray-bounds]
          Lisp_Object face_prop = XVECTOR_DATA (prop)[1];
                                  ^                   ~
In file included from /playpen/src/XEmacs/xemacs/src/frame.c:366:
/playpen/src/XEmacs/xemacs/src/lisp.h:2709:25: note: instantiated from:
#define XVECTOR_DATA(s) vector_data (XVECTOR (s))
                        ^
/playpen/src/XEmacs/xemacs/src/lisp.h:2708:24: note: instantiated from:
#define vector_data(v) ((v)->contents)
                       ^
/playpen/src/XEmacs/xemacs/src/lisp.h:2695:15: note: array 'contents' declared here
  Lisp_Object contents[1];
              ^
------------------------------------------------------------------------------

Is there an idiom for this that won't offend clang?  Or should I turn
off -Warray-bounds for clang?



More information about the XEmacs-Beta mailing list