Subject: bug#10727: 23.3; compilation-next-error misinterprets gcc errors with column info

From: [email-masked]
Date: Sat, 04 Feb 2012 14:03:05 -0500

Newer versions of gcc supply the column and line number of errors by
default. This causes the next-error command to fail to interpret the
filename in some cases.

To replicate:
* Create these files: 
       test.cc  which contains:
                 #include "test.h"
       test.h   which contains:
                 calss a();

* M-x compile with an argument "g++ test.cc", using a version of gcc
  that outputs columns (4.5 and higher does for sure).

* The compilation buffer will contain:

-*- mode: compilation; default-directory: "/Users/patrik/" -*-
Compilation started at Sat Feb  4 13:50:36

g++-fsf-4.6 test.cc 
In file included from test.cc:1:0:
test.h:1:1: error: 'calss' does not name a type

Compilation exited abnormally with code 1 at Sat Feb  4 13:50:36

* now do next-error (C-x `). The minibuffer will display:
  Find this error in (default test.cc:1):

Expected behavior is that it will find the error in test.cc. Doing
next-error again will correctly find the actual error at test.h:1. It
seems to be only the "In file included from..." errors that are
mis-parsed. 

I have tried to trace this in the debugger but have only gotten to
the macro compilation-loop in the compilation-next-error function in
compile.el. It seems the error is in how the properties are set in the
compilation buffer, because apparently these functions only look at the
test properties. 

A workaround is to use the argument -fno-show-column to gcc, but the
column numbers are actually useful so it would be nice to have this work correctly.

In GNU Emacs 23.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 2.24.8)
 of 2012-01-13 on x86-04.phx2.fedoraproject.org
Windowing system distributor `The X.Org Foundation', version 11.0.11003000
configured using `configure  '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--program-prefix=' '--disable-dependency-tracking' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-dbus' '--with-gif' '--with-jpeg' '--with-png' '--with-rsvg' '--with-tiff' '--with-xft' '--with-xpm' '--with-x-toolkit=gtk' 'build_alias=x86_64-redhat-linux-gnu' 'host_alias=x86_64-redhat-linux-gnu' 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4  -m64 -mtune=generic' 'LDFLAGS=-Wl,-z,relro ''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: C
  value of $XMODIFIERS: nil
  locale-coding-system: nil
  default enable-multibyte-characters: t

Major mode: C++/l

Minor modes in effect:
  tooltip-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-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Recent input:
C-x c <escape> x c o m p i l e <return> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> g + + SPC t e s t . c c <return> 
C-x ` C-g <escape> x r e p o r t - e m a c s - b u 
g <return>

Recent messages:
Loading /usr/share/emacs/site-lisp/site-start.d/focus-init.el (source)...done
Loading /usr/share/emacs/site-lisp/site-start.d/php-mode-init.el (source)...done
Loading /usr/share/emacs/site-lisp/site-start.d/rpm-spec-mode-init.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
Loading vc-hg...done
(No files need saving)
Compilation exited abnormally with code 1
Quit

Load-path shadows:
None found.

Features:
(shadow sort mail-extr message sendmail ecomplete rfc822 mml mml-sec
password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231
rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc
time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock sha1
hex-util hashcash mail-utils emacsbug compile comint ring vc-hg cc-mode
cc-fonts easymenu cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars
cc-defs regexp-opt tooltip ediff-hook vc-hooks lisp-float-type mwheel
x-win x-dnd font-setting tool-bar dnd fontset image fringe lisp-mode
register page menu-bar rfn-eshadow timer select scroll-bar mldrag mouse
jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
loaddefs button minibuffer faces cus-face files text-properties overlay
md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
system-font-setting font-render-setting gtk x-toolkit x multi-tty emacs)