make-w32
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug report: Compile with Microsoft and Intel compiler


From: Jerker Bäck
Subject: Bug report: Compile with Microsoft and Intel compiler
Date: Mon, 25 Apr 2005 16:57:01 +0200

Bug report from compile with Microsoft and Intel compiler
Microsoft compiler: 1310.2190 from DDK 2003
Intel compiler: 8.1.025 
C Runtime library used: Microsoft multithreaded CRT 6.9782 (VC6 SP6)

Comments:
Compilation is made with /W4 /WX + inclusion of warning.h.
This means maximum diagnostics and that all warnings becomes errors.
Errors in 4XXX can be disabled, 2XXX errors must be fixed

The type conversions may seem trivial but it is a simple work to get rid of
them once and for all. Are they all type safe?

The file time macros do not seem to work att all - severe bug?


Proposed addtions:

Missing header:
#include <direct.h>    (for chdir)
place in make.h (ie line 364)

To support calling conventions:
#if !defined(__cdecl) && !defined(_MSC_VER)
#define C_CALLBACK
#else 
#define C_CALLBACK __cdecl
#endif

place in make.h (ie line 365)

Disable some trivial annoying warnings:
#pragma warning(disable : 4100)         // unreferenced formal parameter
#pragma warning(disable : 4127)         // conditional expression is
constant
#pragma warning(disable : 4131)         // uses old-style declarator

----------------------------------
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
----------------------------------

make.h(286) error C2373: redefinition;
#undef  ANSI_STRING
#undef  strerror
#if !defined(ANSI_STRING) && !defined(__DECC)
extern char *strerror PARAMS ((int errnum));
#endif

This will always redefine strerror unless __DECC
solution:
#if !defined(__DECC) && !defined(_MSC_VER)
----------------------------------
make.h(481):error C2373: redefinition; different type modifiers
#ifdef  HAVE_GETCWD
# if !defined(VMS) && !defined(__DECC)
extern char *getcwd ();
#endif
#else
extern char *getwd ();
# define getcwd(buf, len)       getwd (buf)
#endif

solution:
#include <direct.h> at line 364
# if !defined(VMS) && !defined(__DECC) && !defined(_MSC_VER)
----------------------------------
make.h(490) error C4273: inconsistent dll linkage
extern char **environ;

solution:
#if !defined(_MSC_VER)
-----------------------------------
ar.c(301):error C4113:differs in parameter lists
ar.c(301):error C2440:cannot convert from __stdcall to __cdecl

solution: 
make.h(45)
#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
# undef  PARAMS
# define PARAMS(protos)  protos
#else /* Not C++ or ANSI C.  */
# undef  PARAMS
# define PARAMS(protos)  ()
#endif /* C++ or ANSI C.  */

change to
#if defined (__cplusplus) || (defined (__STDC__) && __STDC__) || defined
(_MSC_EXTENSIONS)

make.h(428):
extern int alpha_compare PARAMS((const void *, const void *));
change to
extern int C_CALLBACK alpha_compare PARAMS((const void *, const void *));

misc.c(62):
int alpha_compare (const void *v1, const void *v2)
change to
int C_CALLBACK alpha_compare (const void *v1, const void *v2)
-----------------------------------
arscan.c(611) : error C4057: differs in indirection to slightly different
base types
sscanf(member_header.ar_mode, "%o", &eltmode);

solution:
sscanf((const char*)member_header.ar_mode, "%o", &eltmode);

likewise in arscan.c line 612,622,623,624 and 793
----------------------------------
commands.c(36):error C2373:redefinition; different type modifiers
#ifndef HAVE_UNISTD_H
extern int getpid ();
#endif

solution:
#if !defined(getpid) && !defined(_MSC_VER)
----------------------------------
commands.c(355):error C4242: conversion to smaller type, possible loss of
data
cmds->lines_flags[idx] = flags;

solution:
cmds->lines_flags[idx] = (char)flags;
----------------------------------
dir.c(141):error C4242: conversion to smaller type, possible loss of data
*df++ = tolower((unsigned char)*filename);

solution:
*df++ = (char)tolower((unsigned char)*filename);
----------------------------------
dir.c(522):error C4057: differs in indirection to slightly different base
types
if (GetVolumeInformation(w32_path,
     fs_label, sizeof (fs_label),
         &fs_serno, &fs_len,
         &fs_flags, fs_type, sizeof (fs_type)) == FALSE)

solution:
Wrong type - could cause serious errors
change dir.c line 422
#ifdef WINDOWS32
  char* w32_path;
  char  fs_label[BUFSIZ];
  char  fs_type[BUFSIZ];
  unsigned long fs_serno;
  unsigned long fs_flags;
  unsigned long fs_len;
#endif
----------------------------------
dir.c(614):error C4242:conversion to smaller type, possible loss of data
dirfile_key.length = strlen (filename);

solution:
dirfile_key.length = (short)strlen (filename);

likewise dir.c line 679,691,863 and 940
----------------------------------
dir.c(1167):error C2373: different type modifiers
#ifndef stat
# ifndef VMS
extern int stat PARAMS ((const char *path, struct stat *sbuf));
# endif

solution:
#if !defined(VMS) && !defined(_MSC_VER)
----------------------------------
dir.c(639):error C4701: local variable may be used without having been
initialized

solution:
dir.c(578)
struct stat st = {0};
----------------------------------
dir.c(1185):error C4113: differs in parameter lists
dir.c(1186):error C4113: differs in parameter lists
dir.c(1188):error C2440: cannot convert from __stdcall to __cdecl
  gl->gl_opendir = open_dirstream;
  gl->gl_readdir = read_dirstream;
  gl->gl_closedir = ansi_free;
  gl->gl_stat = local_stat;

solution:
glob.h line 27
__PMT will not be correctly defined since __P is already defined in hash.h
...
# if !defined __GLIBC__ || !defined __P
#  undef __P
#  undef __PMT
#  define __P(protos)   protos
#  define __PMT(protos) protos
#  if !defined __GNUC__ || __GNUC__ < 2
#   undef __const
#   define __const const
#  endif
# endif
# define __ptr_t        void *
#else /* Not C++ or ANSI C.  */
# undef __P
# undef __PMT
# define __P(protos)    ()
# define __PMT(protos)  ()
...
change line 27 to 
#if !defined __GLIBC__

glob.h line 136
int (*gl_stat) __PMT((__const char *, struct stat *, ...));
change to
int (C_CALLBACK *gl_stat) __PMT((__const char *, struct stat *, ...));
----------------------------------
file.c(553):error C4296: expression is always false
file.c(553):error C4307: integral constant overflow
file.c(554):error C4296: expression is always false
file.c(554):error C4307: integral constant overflow
file.c(557):error C4296: expression is always false
file.c(557):error C4307: integral constant overflow

This is apparently not working at all

Solution ?????????
----------------------------------
function.c(270):error C4244: conversion to smaller type, possible loss of
data
function_table_entry_key.len = e - s;
solution:
function_table_entry_key.len = (unsigned char)(e - s);
----------------------------------
function.c(512):error C4130: logical operation on address of string constant
function.c(536):error C4130: logical operation on address of string constant
function.c(570):error C4130: logical operation on address of string constant
function.c(622):error C4130: logical operation on address of string constant
function.c(910):error C4130: logical operation on address of string constant

solution:
coding style
#pragma warning(disable : 4130)
----------------------------------
function.c(678):error C4706: assignment within conditional expression
function.c(2060):error C4706: assignment within conditional expression

solution:
coding style
#pragma warning(disable : 4706)
----------------------------------
function.c(1020):error C4242: conversion to smaller type, possible loss of
data
pp->str[pp->length] = pp->save_c;

solution:
pp->str[pp->length] = (char)pp->save_c;
----------------------------------
function.c(1612):error C4057: differs in indirection to slightly different
base
fold_newlines (buffer, &i);

solution:
fold_newlines (buffer, (int*)&i);
----------------------------------
fnmatch.c(123): error C2373: redefinition;
# if !defined _LIBC && !defined getenv
extern char *getenv ();
# endif

solution:
# if !defined _LIBC && !defined getenv && !defined(_MSC_VER)
----------------------------------
fnmatch.c(176):error C4244: conversion to smaller type, possible loss of
data

solution:
c = FOLD (c);
c = (unsigned char)FOLD (c);

likewise in fnmatch.c line 176,198,273,320 and 326
----------------------------------
fnmatch.c(484):error C4028: formal parameters different from declaration
warning #147: declaration is incompatible with
"int fnmatch(char *, char *, int)" 
(declared at line 77 of "..\glob\fnmatch.h")

solution: fnmatch.h(39)
#ifndef const
# if (defined __STDC__ && __STDC__) || defined __cplusplus
#  define __const       const
# else
#  define __const
# endif
#endif

change to:
# if (defined __STDC__ && __STDC__) || defined __cplusplus  || defined
WINDOWS32
----------------------------------
hash.c(49):error C4115: named type definition in parentheses
likewise at line 265

solution:
coding style
#pragma warning(disable : 4115)
----------------------------------
getopt.c(209):error C2373: redefinition; different type modifiers
#ifndef getenv
extern char *getenv ();
#endif

solution:
#if !defined getenv && !defined(_MSC_VER)
----------------------------------
hash.c(312):error C2440: cannot convert from __stdcall to __cdecl

solution: 
change hash.h line 59
typedef int (*qsort_cmp_t) __P((void const *, void const *));
to
typedef int (C_CALLBACK *qsort_cmp_t) __P((void const *, void const *));
----------------------------------
implicit.c(279):error C4242: conversion, possible loss of data
implicit.c(416):error C4242: conversion, possible loss of data
implicit.c(446):error C4242: conversion, possible loss of data

solution:
checked_lastslash[nrules] = (char)check_lastslash;
found_files_im[deps_found] = (unsigned char)dep->ignore_mtime;
----------------------------------
job.c(180):error C2373: redefinition; different type modifiers
job.c(181):error C2373: redefinition; different type modifiers
job.c(182):error C2373: redefinition; different type modifiers

#ifndef HAVE_UNISTD_H
extern int dup2 ();
extern int execve ();
extern void _exit ();
# ifndef VMS
extern int geteuid ();
extern int getegid ();
extern int setgid ();
extern int getgid ();
# endif
#endif

solution:
#ifndef HAVE_UNISTD_H
#if !defined(_MSC_VER)
extern int dup2 ();
extern int execve ();
extern void _exit ();
#endif
...
----------------------------------
job.c(540):error C4101: unreferenced local variable
job.c(542):error C4189: local variable is initialized but not referenced
job.c(621):error C4102: unreferenced label
job.c(1441):error C4102: unreferenced label

solution:
status, reap_more
remote_status_lose:, error: 

?????
comment out is not safe - may be needed

#pragma warning(disable : 4101)
#pragma warning(disable : 4102)
#pragma warning(disable : 4189)
----------------------------------
job.c(750):error C4389: signed/unsigned mismatch
if(c->remote == remote && c->pid == pid)

solution:
if(c->remote == (unsigned int)(remote && c->pid == pid))
----------------------------------
job.c(740):error C4701: local variable may be used without having been
initialized
job.c(787):error C4701: local variable may be used without having been
initialized

solution: 
job.c(564)
int exit_code = 0, exit_sig = 0, coredump = 0;
----------------------------------
main.c(77):error C2373: redefinition; different type modifiers
#ifndef HAVE_UNISTD_H
extern int chdir ();
#endif

solution:
#if !defined(HAVE_UNISTD_H) && !defined(_MSC_VER)
----------------------------------
main.c(823):error C2373: redefinition; different type modifiers
extern char *mktemp PARAMS ((char *template));

solution:
#if !defined(_MSC_VER)
----------------------------------
main.c(831):error C4101: unreferenced local variable

solution: comment out
int fd
----------------------------------
main.c(873) : error C4007: 'main' : must be '__cdecl'

solution:
MSDN: Attribute is not explicitly stated. The compiler forces the attribute

It is then OK to disable this warning
#pragma warning(disable : 4007)
----------------------------------
main.c(953):error C2440: cannot convert from __stdcall to __cdecl
FATAL_SIG (SIGINT);

solution:
in main.c line 64
extern RETSIGTYPE fatal_error_signal PARAMS((int sig));
change to
extern RETSIGTYPE C_CALLBACK fatal_error_signal PARAMS((int sig));
in commands.c line 401
RETSIGTYPE
change to
RETSIGTYPE C_CALLBACK
----------------------------------
main.c(1481):error C4210: nonstandard extension used : function given file
scope
extern RETSIGTYPE child_handler PARAMS ((int sig));

solution:
place the prototype outside of function
----------------------------------
main.c(1725):error C4296: expression is always false
f->last_mtime = f->mtime_before_update = NEW_MTIME;

solution: ??
----------------------------------
main.c(2131):error C4242: conversion, possible loss of data
*p++ = switches[i].c;

solution:
*p++ = (char)switches[i].c;

likewise at main.c line 2663
----------------------------------
read.c(1462):error C4244: conversion, possible loss of data
= (v != 0 && *v->value != '\0') == notdef;

solution:
= (char)((v != 0 && *v->value != '\0') == notdef);

likewise at read.c line 1558
= (char)(streq (s1, s2) == notdef);
----------------------------------
read.c(1790):error C4130:logical operation on address of string constant
if (streq (name, ".POSIX"))

solution:
coding style
#pragma warning(disable : 4130)
----------------------------------
read.c(2484):error C4245: conversion, signed/unsigned mismatch
static unsigned long
readstring (struct ebuffer *ebuf)
{
  char *eol;
  if (ebuf->bufnext >= ebuf->bufstart + ebuf->size)
    return -1;

solution: (type safe?)
return (unsigned long)-1;
----------------------------------
read.c(2916):error C4210: nonstandard extension used : function given file
scope
read.c(2916):error C2373: redefinition; different type modifiers
#ifndef VMS
  if (name[1] == '/' || name[1] == '\0')
    {
      extern char *getenv ();

solution:
#if !defined(_MSC_VER)
      extern char *getenv ();
#endif
----------------------------------
read.c(2994):error C4210: nonstandard extension used : function given file
scope
extern void dir_setup_glob ();

solution:
place the prototype outside of function
----------------------------------
remake.c(431):error C4296: expression is always false
remake.c(431):error C4307: integral constant overflow

solution: ?????
----------------------------------
remake.c(606):error C4242: conversion, possible loss of data
remake.c(823):error C4242: conversion, possible loss of data
file->update_status = dep_status;
file->update_status = touch_file (file);

solution:
file->update_status = (short)dep_status;
file->update_status = (short)touch_file (file);
----------------------------------
remake.c(862):error C4296: expression is always false
file->last_mtime = i == 0 ? UNKNOWN_MTIME : NEW_MTIME;

solution: ?????
----------------------------------
rule.c(396):error C4242: conversion, possible loss of data
rule.c(514):error C4242: conversion, possible loss of data
r->terminal = terminal;

solution:
r->terminal = (char)terminal;
----------------------------------
signame.c(241):error C4242: conversion, possible loss of data
sig_initted = signame_init ();

solution:
sig_initted = (char)signame_init ();
----------------------------------
variable.c(285):error C4130: logical operation on address of string constant
variable.c(868):error C4130: logical operation on address of string constant
variable.c(1118):error C4130: logical operation on address of string
constant

solution:
coding style
#pragma warning(disable : 4130)
----------------------------------
vpath.c(533):error C4701: local variable may be used without having been
initialized
*mtime_ptr = (exists_in_cache
      ? FILE_TIMESTAMP_STAT_MODTIME (name, st)
        : UNKNOWN_MTIME);

solution: (good?)
vpath.c(503)
if (exists)
{
        struct stat st = {0};
----------------------------------
glob.c(500):error C4389: signed/unsigned mismatch
glob.c(871):error C4018: signed/unsigned mismatch
glob.c(922):error C4389: signed/unsigned mismatch
glob.c(949):error C4018: signed/unsigned mismatch
glob.c(1011):error C4018: signed/unsigned mismatch
glob.c(1029):error C4018: signed/unsigned mismatch
glob.c(1052):error C4018: signed/unsigned mismatch
glob.c(1072):error C4018: signed/unsigned mismatch
if (pglob->gl_pathc != firstc)
...

solution:
if (pglob->gl_pathc != (__size_t)firstc)
for (i = 0; i < (int)dirs.gl_pathc; ++i)
if ((flags & GLOB_DOOFFS) && ignore < (int)pglob->gl_offs)
if ((flags & GLOB_DOOFFS) && pglob->gl_offs > (__size_t)oldcount)
----------------------------------
glob.c(570):error C4013: func undefined; assuming extern returning int

solution:
glob.c line 302
#ifdef VMS
#if !defined _LIBC || !defined NO_GLOB_PATTERN_P
int __glob_pattern_p (const char *pattern, int quote);
#endif
#endif

change to
#if defined(VMS) || defined(_MSC_VER)
----------------------------------
glob.c(1057):error C2440:  cannot convert from __stdcall to __cdecl

solution
glob.c(300)
static int C_CALLBACK collated_compare __P((const __ptr_t, const __ptr_t));
glob.c(1081)
static int C_CALLBACK collated_compare (a, b)
----------------------------------
glob.c(1156):error C4242:  conversion, possible loss of data

solution:
new[dirlen] = (char)DIRSEP_CHAR;
----------------------------------
dirent.c(117):error C4245: conversion, signed/unsigned mismatch

solution:
pDir->dir_sdReturn.d_ino = (ino_t)-1;
----------------------------------
sub_proc.c(539) : error C4213: nonstandard extension used : cast on l-value
sub_proc.c(543) : error C4213: nonstandard extension used : cast on l-value
sub_proc.c(547) : error C4213: nonstandard extension used : cast on l-value
sub_proc.c(677) : error C4213: nonstandard extension used : cast on l-value
sub_proc.c(742) : error C4213: nonstandard extension used : cast on l-value
sub_proc.c(750) : error C4213: nonstandard extension used : cast on l-value
sub_proc.c(758) : error C4213: nonstandard extension used : cast on l-value
(HANDLE)pproc->sv_stdin[1] = 0;

solution:
pproc->sv_stdin[1] = 0;

likewise sub_proc.c line 543,547,677,742,750,758
----------------------------------
sub_proc.c(765) : error C4057: differs in indirection to slightly different
base types
sub_proc.c(855) : error C4057: differs in indirection to slightly different
base types

solution:
sub_proc.c(26)
typedef struct sub_process_t {
        int sv_stdin[2];
        int sv_stdout[2];
        int sv_stderr[2];
        int using_pipes;
        char *inp;
        DWORD incnt;
        char * volatile outp;
        volatile DWORD outcnt;
        char * volatile errp;
        volatile DWORD errcnt;
        int pid;
        int exit_code;
        int signal;
        long last_err;
        long lerrno;
} sub_process;

change to
unsigned long exit_code;
----------------------------------
sub_proc.c(782):error C4701: local variable may be used without having been
initialized
sub_proc.c(784):error C4701: local variable may be used without having been
initialized
sub_proc.c(786):error C4701: local variable may be used without having been
initialized

solution: (good?)
sub_proc(660)
HANDLE tStdin, tStdout, tStderr;

change to
HANDLE tStdin = 0, tStdout = 0, tStderr = 0;
----------------------------------
sub_proc.c(575) : error C4702: unreachable code
sub_proc.c(607) : error C4702: unreachable code
sub_proc.c(638) : error C4702: unreachable code

solution:
coding style
#pragma warning(disable : 4702)
----------------------------------
pathstuff.c(49):error C4706: assignment within conditional expression
pathstuff.c(91):error C4706: assignment within conditional expression

solution:
coding style
#pragma warning(disable : 4706)
----------------------------------

OPTIONAL:
To remove dependencies of USER32.DLL
change w32err.c(20)
wsprintf (szMessageBuffer, "Error %ld\n", ercode);
   to
sprintf (szMessageBuffer, "Error %ld\n", ercode);



To reproduce:
use config.h.w32 as config.h
Catch all redefines by include a forced header
/FI"vc_def.h"
Set full warning level /W4 /WX
Use __stdcall calling conventions /Gz

vc_def.h:
<---------------------
#pragma once

// To ensure the right headers are included
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/timeb.h>
#include <time.h>
#include <locale.h>
#include <signal.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <memory.h>
#include <malloc.h>
#include <assert.h>
#include <process.h>
#include <direct.h>

#pragma warning(disable : 4100)         // unreferenced formal parameter
#pragma warning(disable : 4127)         // conditional expression is
constant
#pragma warning(disable : 4131)         // uses old-style declarator

#ifndef _DEBUG
#pragma warning(disable : 4007)         // 'main' : must be '__cdecl'
#pragma warning(disable : 4101)         // unreferenced local variable
#pragma warning(disable : 4102)         // unreferenced label
#pragma warning(disable : 4115)         // named type definition in
parentheses
#pragma warning(disable : 4130)         // logical operation on address of
string constant
#pragma warning(disable : 4189)         // local variable is initialized but
not referenced
#pragma warning(disable : 4296)         // expression is always false
#pragma warning(disable : 4307)         // integral constant overflow
#pragma warning(disable : 4702)         // unreachable code
#pragma warning(disable : 4706)         // assignment within conditional
expression
#endif

#if defined(__INTEL_COMPILER)   // May not work use /Qwd193,310
#pragma warning(disable : 193)
#pragma warning(disable : 279)  // controlling expression is constant
#pragma warning(disable : 310)
#pragma warning(disable : 1418) // external definition with no prior
declaration
#pragma warning(disable : 1419) // external declaration in primary source
file
#endif

------------->

Kind regards
Jerker Bäck 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]