Subject: 23.1.96; compilation-next-error broken

From: stephe <[email-masked]>
Date: Tue, 20 Apr 2010 05:45:02 -0400

Starting from `emacs -Q':

open this C file:

------------
int main (int argc, char *argv[])
{

   printf ("missing include\n");
   printf ("missing paren";
   return 0;
} /* end main */
/* end of file */
------------

(note that it is missing a #include, and is missing a paren)

Attempt to compile it:

M-x compile

Change the compile command to:

gcc test.c

This gives a list of compilation errors:

-*- mode: compilation; default-directory: "/home/stephe/" -*-
Compilation started at Tue Apr 20 05:25:38

gcc test.c
test.c: In function ‘main’:
test.c:4: warning: incompatible implicit declaration of built-in function ‘printf’
test.c:5: error: expected ‘)’ before ‘;’ token
test.c:7: error: expected ‘;’ before ‘}’ token

Compilation exited abnormally with code 1 at Tue Apr 20 05:25:38
------------

Go to the first error: C-x ` . point is now on the line that prints
"missing include". Fix the problem by adding a line "#include <stdio.h>"
at the top of the buffer. Now the line number in the next error message
is wrong, but Emacs used to handle that by using markers appropriately.

Now go to the next error: C-x `. Point should be on the line that prints
"missing paren", but it is on the previous line (the current line 5).

The problem seems to be in compilation-next-error. It has a mechanism
that sets markers based on the line/column info in the error messages,
assuming the file has not changed. It puts file mod timestamps in the
compilation error structure to record that this has been done, so it
doesn't get done again (after the buffer has changed). However, it
doesn't set the timestamp in every line, and when it gets to a line
without a timestamp, it processes the marker info again, which is wrong.

I don't have a fix.

This same bug is in trunk (emacs version 24.0.50.2, bzr rev 99948)

In GNU Emacs 23.1.96.1 (i686-pc-linux-gnu, GTK+ Version 2.18.6)
 of 2010-04-20 on Shevek
Windowing system distributor `The Cygwin/X Project', version 11.0.10706000
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: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Lisp Interaction

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

Recent input:
M-x r e p o r t - e m a c s - b u g <return>

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 message sendmail regexp-opt ecomplete rfc822 mml
easymenu 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 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 font-render-setting gtk x-toolkit x
multi-tty emacs)