www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/06/08/17:35:55

From: Martin Str|mberg <ams AT ludd DOT luth DOT se>
Message-Id: <200106082135.XAA13989@mother.ludd.luth.se>
Subject: Re: Compiler options for djdev build
To: djgpp-workers AT delorie DOT com
Date: Fri, 8 Jun 2001 23:35:39 +0200 (MEST)
In-Reply-To: <4331-Fri08Jun2001133527+0300-eliz@is.elta.co.il> from "Eli Zaretskii" at Jun 08, 2001 01:35:27 PM
X-Mailer: ELM [version 2.5 PL2]
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

According to Eli Zaretskii:
> 
> Per past discussions, here are the compiler options I suggest to add
> to gcc.opt and gcc-l.opt:
> 
>   -Wundef
>   -Wcast-align
>   -Wconversion
>   -Wsign-compare
> 
> I didn't yet try to build the library with these; perhaps someone
> could try that.

I did. We get a lot of warnings. Here's some diffs reflecting changes
necessary (hand-pasted in):

Index: src/libc/ansi/locale/mbstowcs.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/ansi/locale/mbstowcs.c,v
retrieving revision 1.1
diff -p -u -r1.1 mbstowcs.c
--- src/libc/ansi/locale/mbstowcs.c     1994/11/29 09:18:20     1.1
+++ src/libc/ansi/locale/mbstowcs.c     2001/06/08 21:19:36
@@ -4,8 +4,8 @@
 size_t
 mbstowcs(wchar_t *wcs, const char *s, size_t n)
 {
-  int i;
-  for (i=0; s[i] && (i<n-1); i++)
+  size_t i;
+  for (i=0; s[i] && (i+1<n); i++)
     wcs[i] = s[i];
   wcs[i] = 0;
   return i;
Index: src/libc/ansi/locale/wcstombs.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/ansi/locale/wcstombs.c,v
retrieving revision 1.1
diff -p -u -r1.1 wcstombs.c
--- src/libc/ansi/locale/wcstombs.c     1994/11/29 09:18:12     1.1
+++ src/libc/ansi/locale/wcstombs.c     2001/06/08 21:19:36
@@ -4,8 +4,8 @@
 size_t
 wcstombs(char *s, const wchar_t *wcs, size_t n)
 {
-  int i;
-  for (i=0; wcs[i] && (i<n-1); i++)
+  size_t i;
+  for (i=0; wcs[i] && (i+1<n); i++)
     s[i] = wcs[i];
   s[i] = 0;
   return i;
Index: src/libc/ansi/stdio/doprnt.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/ansi/stdio/doprnt.c,v
retrieving revision 1.8
diff -p -u -r1.8 doprnt.c
--- src/libc/ansi/stdio/doprnt.c        1999/07/04 14:18:04     1.8
+++ src/libc/ansi/stdio/doprnt.c        2001/06/08 21:19:42
@@ -327,7 +327,7 @@ _doprnt(const char *fmt0, va_list argp, 
         */
        char *p                 /*, *memchr() */;
 
-       if ((p = memchr(t, 0, prec)))
+       if ((p = memchr(t, 0, (size_t)prec)))
        {
          size = p - t;
          if (size > prec)
Index: src/libc/ansi/stdio/doscan.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/ansi/stdio/doscan.c,v
retrieving revision 1.9
diff -p -u -r1.9 doscan.c
--- src/libc/ansi/stdio/doscan.c        1999/08/03 08:49:23     1.9
+++ src/libc/ansi/stdio/doscan.c        2001/06/08 21:19:45
@@ -366,7 +366,8 @@ _instr(char *ptr, int type, int len, FIL
 static const char *
 _getccl(const unsigned char *s)
 {
-  register int c, t;
+  register int t;
+  size_t c;
 
   t = 0;
   if (*s == '^') {

> Finally, do we still need -fno-strength-reduce?  I'd think we could
> remove that now.  If we are not sure, perhaps someone could ask on the
> GCC mailing list.

I'm trying with that one removed.


Some warnings I don't understand and can't get to go away (I only
tried to remove the todigit ones and gave up):

make -C ansi/stdio 
gcc ... -c doprnt.c
cc1.exe: warnings being treated as errors
doprnt.c: In function `_doprnt':
doprnt.c:167: warning: passing arg 1 of `todigit' with different width due to prototype
doprnt.c:184: warning: passing arg 1 of `todigit' with different width due to prototype
doprnt.c:277: warning: passing arg 5 of `cvtl' with different width due to prototype
doprnt.c: In function `cvtl':
doprnt.c:597: warning: passing arg 5 of `roundl' with different width due to prototype
doprnt.c:621: warning: passing arg 5 of `roundl' with different width due to prototype
doprnt.c:683: warning: passing arg 5 of `roundl' with different width due to prototype
doprnt.c:696: warning: passing arg 3 of `exponentl' with different width due to prototype
doprnt.c:763: warning: passing arg 5 of `roundl' with different width due to prototype
doprnt.c: In function `roundl':
doprnt.c:800: warning: passing arg 1 of `todigit' with different width
due to prototype
make.exe[3]: *** [doprnt.o] Error 1
make.exe[2]: *** [all_subs] Error 2
make.exe[1]: *** [all] Error 2
make.exe: *** [subs] Error 2

Finally an observation. Look at doscan.c above. We have variables
declared as register. As I understand this this make optimisation by
the compiler difficult. Shouldn't we change to not use "register"?


Right,

						MartinS

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019