Hi

I've compiled Vim-7.3e (2539:9397d2d76340) with the clang compiler on Linux.

All tests pass.  However, I see something wrong when doing:

  $ vim -c 'saveas! /tmp/foo'

Vim prints:

  "/tmp/foo" [New File] 0 lines, 585937717901131776 characters written

Obviously the number of characters written is not correct (should be 0).

Valgrind also reports:

==18757== Conditional jump or move depends on uninitialised value(s)
==18757==    at 0x496935B: _itoa (_itoa.c:442)
==18757==    by 0x496CC85: vfprintf (vfprintf.c:1613)
==18757==    by 0x498B70B: vsprintf (iovsprintf.c:43)
==18757==    by 0x49741DA: sprintf (sprintf.c:34)
==18757==    by 0x80D850C: msg_add_lines (fileio.c:5246)
==18757==    by 0x80DB5EC: buf_write (fileio.c:4885)
==18757==    by 0x80A24B0: do_write (ex_cmds.c:2706)
==18757==    by 0x80A256B: ex_write (ex_cmds.c:2519)
==18757==    by 0x80BA4D8: do_one_cmd (ex_docmd.c:2656)
==18757==    by 0x80B739F: do_cmdline (ex_docmd.c:1122)
==18757==    by 0x80B7F7E: do_cmdline_cmd (ex_docmd.c:728)
==18757==    by 0x8100D64: exe_commands (main.c:2807)
==18757==    by 0x80FE1FC: main (main.c:885)
==18757==  Uninitialised value was created by a stack allocation
==18757==    at 0x80D8494: msg_add_lines (fileio.c:5238)

And while compiling, I see this warning which points to the same problem:

fileio.c:5248:13: warning: conversion specifies type 'long long' but
the argument has type 'off_t' (aka 'long')
      [-Wformat]
                "%ldL, %lldC", lnum, nchars
                       ~~~^~         ~~~~~~

The number of characters is printed in fileio.c:5248:

 5233     void
 5234 msg_add_lines(insert_space, lnum, nchars)
 5235     int     insert_space;
 5236     long    lnum;
 5237     off_t   nchars;
 5238 {
 5239     char_u  *p;
 5240
 5241     p = IObuff + STRLEN(IObuff);
 5242
 5243     if (insert_space)
 5244         *p++ = ' ';
 5245     if (shortmess(SHM_LINES))
 5246         sprintf((char *)p,
 5247 #ifdef LONG_LONG_OFF_T
!5248                 "%ldL, %lldC", lnum, nchars
 5249 #else
 5250                 /* Explicit typecast avoids warning on Mac OS X 10.6 */
 5251                 "%ldL, %ldC", lnum, (long)nchars
 5252 #endif
 5253                 );

Adding debug printf, I see that we have with clang:
 * sizeof(off_t) == 4
 * sizeof(long long) == 8

Yet in src/auto/config.h, I see this (which is thus incorrect):

  /* Defined to the size of off_t */
  #define SIZEOF_OFF_T 8

The configure script is getting SIZEOF_OFF_T incorrectly when using
clang compiler.

In src/auto/config.log, I see:

configure:11536: checking size of off_t
configure:11541: clang -o conftest -g -O2   -L/usr/local/lib
conftest.c -lm -lncurses -lnsl  -lselinux -lacl -lattr -lgpm >&5
configure:11541: $? = 0
configure:11541: ./conftest
configure:11541: $? = 0
configure:11556: result: 8

Why do we compute size of 'off_t' in configure script, rather than
simply use sizeof(off_t)?

PS:  You can install the clang compiler on Ubuntu with "sudo apt-get
install clang".
I had to add #include <wchar.h> in vim.h to be able to compile Vim successfully
with clang.

-- Dominique

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui