Hi,

I have been using a hack to deal with this bug for over a year now. I believe I am seeing this problem ever since I starting understanding more and more of elisp, around emacs 24.3.

Problem: 
- I save the frame width using `frame-pixel-width' to a defvar.
- I then set the frame size using `set-frame-size' with that defvar as one of the args
- I notice that the frame had got wider! When I do a readback using `frame-pixel-width', it is exactly 16 pixels wider than expected.

I have seen this problem on emacsen built earlier on RHEL 5 and now on RHEL 6 too.

Evaluate the below code in the scratch buffer in an emacs -Q session. Then when you keep on hitting F2, you will see that the frame keeps on getting wider. 

Now if you uncomment the line with the "<-- HACK" comment, reeval the code and then keep on hitting F2, the frame width will stay the same (which was the end goal of the below code).



(defvar bkp--frame-height-px nil)
(defvar bkp--frame-width-px nil)

(defun modi/toggle-menu-bar ()
  "Toggle the menu bar.
Also restore the original frame size when disabling the menu bar."
  (interactive)
  (let ((frame-resize-pixelwise t))
    ;; If the menu bar is hidden currently, take a backup of the frame height.
    (when (null menu-bar-mode)
      (setq bkp--frame-height-px (frame-pixel-height))
      (setq bkp--frame-width-px  (frame-pixel-width))

      ;; ;; `frame-pixel-width' is returning a value higher by 16 pixels compared
      ;; ;; to that set using `set-frame-size'. So the below adjustment has to be made.
      ;; (setq bkp--frame-width-px  (- (frame-pixel-width) 16))) ; <-- HACK

    (menu-bar-mode 'toggle)
    ;; Restore frame size if menu bar is hidden after toggle
    (when (null menu-bar-mode)
      (set-frame-size nil bkp--frame-width-px bkp--frame-height-px :pixelwise))))

(global-set-key (kbd "<f2>") #'modi/toggle-menu-bar)



-----------------------------------------------------------------------------------------------------


In GNU Emacs 25.0.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.23)
 of 2015-09-14
Repository revision: 1ee47d477ddb9c567eaf63154f78fad5d5826b78
Windowing system distributor 'The X.Org Foundation', version 11.0.60900000
System Description: Red Hat Enterprise Linux Workstation release 6.6 (Santiago)

Configured using:
 'configure --prefix=/home/kmodi/usr_local/apps/6/emacs/master
 'CPPFLAGS=-fgnu89-inline -I/home/kmodi/usr_local/6/include
 -I/usr/include/freetype2 -I/usr/include'
 'LDFLAGS=-L/home/kmodi/usr_local/6/lib
 -L/home/kmodi/usr_local/6/lib64''

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK2 X11

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=none
  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.
Mark activated
next-line: End of buffer

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message dired format-spec
rfc822 mml mml-sec 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 mail-prsvr mail-utils edmacro kmacro
cl-loaddefs pcase cl-lib time-date mule-util tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win
term/common-win x-dnd 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 inotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 82449 9769)
 (symbols 48 19499 0)
 (miscs 40 49 185)
 (strings 32 13474 4382)
 (string-bytes 1 404277)
 (vectors 16 10887)
 (vector-slots 8 418983 6570)
 (floats 8 131 201)
 (intervals 56 356 10)
 (buffers 976 11)
 (heap 1024 30054 843))


--
Kaushal Modi