Subject: bug#23261: 25.0.92; Undefined behavior in lib/stdint.h

From: Philipp Stephani <[email-masked]>
Date: Sun, 10 Apr 2016 15:51:31 +0200

Clang finds the following undefined behavior in lib/stdint.h:

./lisp.h:3705:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
  XSETPVECTYPE (XVECTOR (v), PVEC_SUB_CHAR_TABLE);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./lisp.h:1124:24: note: expanded from macro 'XSETPVECTYPE'
  ((v)->header.size |= PSEUDOVECTOR_FLAG | ((code) << PSEUDOVECTOR_AREA_BITS))
                       ^~~~~~~~~~~~~~~~~
./lisp.h:763:43: note: expanded from macro 'PSEUDOVECTOR_FLAG'
# define PSEUDOVECTOR_FLAG (PTRDIFF_MAX - PTRDIFF_MAX / 2)
                                          ^~~~~~~~~~~
../lib/stdint.h:520:5: note: expanded from macro 'PTRDIFF_MAX'
    _STDINT_MAX (1, 64, 0l)
    ^~~~~~~~~~~~~~~~~~~~~~~
../lib/stdint.h:126:8: note: expanded from macro '_STDINT_MAX'
   ? ~ _STDINT_MIN (signed, bits, zero) \
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../lib/stdint.h:122:31: note: expanded from macro '_STDINT_MIN'
  ((signed) ? (- ((zero) + 1) << ((bits) ? (bits) - 1 : 0)) : (zero))
               ~~~~~~~~~~~~~~ ^

Could we maybe just remove stdint.h completely?  It should always be
provided by the standard C library.

In GNU Emacs 25.0.92.3 (x86_64-apple-darwin15.4.0, NS appkit-1404.46 Version 10.11.4 (Build 15E65))
 of 2016-04-10 built on p
Repository revision: c8b868b1e2532aa07dbf4959798dbdc52ea9b5d5
Windowing system distributor 'Apple', version 10.3.1404
Configured using:
 'configure --without-xml2 --with-modules'

Configured features:
RSVG IMAGEMAGICK DBUS NOTIFY ACL GNUTLS ZLIB TOOLKIT_SCROLL_BARS NS
MODULES

Important settings:
  value of $LANG: de_DE.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message dired format-spec rfc822 mml
mml-sec password-cache epg epg-config gnus-util mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util help-fns help-mode easymenu
cl-loaddefs pcase cl-lib mail-prsvr mail-utils time-date mule-util
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel ns-win ucs-normalize term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cl-generic cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese charscript case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote dbusbind kqueue cocoa ns multi-tty
make-network-process emacs)

Memory information:
((conses 16 196096 6054)
 (symbols 48 19783 0)
 (miscs 40 43 131)
 (strings 32 15118 5931)
 (string-bytes 1 441818)
 (vectors 16 32893)
 (vector-slots 8 652477 6669)
 (floats 8 162 19)
 (intervals 56 196 0)
 (buffers 976 11))