This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

patch: remaining -Wall warnings


Some of the template instantiations for wchar_t evoke warnings about
comparing signed and unsigned values.  Turns out that gcc is using
unsigned int for wint_t.  That seems like a dubious choice.  But I
don't know what the standard requires of wint_t.

In one case, the code was comparing a wint_t to -2:

	if (_M_istreambuf && _M_c > -2)

But in that comparison, -2 gets implicitly converted to a very large
unsigned value.  So, that one looks like a real bug.

Anyhow, here's a patch to quiet the remaining -Wall warnings.
Also, I added -Wall to the CXXFLAGS so that the code will be
more likely to remain -Wall-friendly going forward.

1999-08-12  Michael Cook  <cook@sightpath.com>

	* bits/fstream.tcc: Fix signed/unsigned -Wall warning.
	* bits/istream.tcc: ditto.
	* bits/sbuf_iter.h: ditto.
	* bits/std_istream.h: ditto.
	* src/Makefile.am: Add -Wall to CXXFLAGS.
	* src/Makefile.in: ditto.

Index: ./bits/fstream.tcc
===================================================================
RCS file: /cvs/libstdc++/libstdc++/bits/fstream.tcc,v
retrieving revision 1.28
diff -u -r1.28 fstream.tcc
--- fstream.tcc	1999/08/11 16:02:43	1.28
+++ fstream.tcc	1999/08/13 02:06:26
@@ -197,7 +197,7 @@
 	  streamsize __size = _M_file->xsgetn(__conv_buf, _M_buf_size);
 	  
 	  // Part two: (Re)fill internal buf contents from external buf.
-	  if (0 < __size && __size <= _M_buf_size)
+	  if (0 < __size && __size <= streamsize(_M_buf_size))
 	    {
 	      _M_set_determinate(__size);
 	      
@@ -225,7 +225,7 @@
 	  
 	  // Part three: Sync the current internal buffer position
 	  // with the (now overshot) external buffer position.
-	  if (__testinout && 0 < __size && __size <= _M_buf_size)
+	  if (__testinout && 0 < __size && __size <= streamsize(_M_buf_size))
 	    {
 	      off_type __sync_off = 0 - __size;
 	      off_type __fail = _M_file->seekoff(__sync_off, 
Index: ./bits/istream.tcc
===================================================================
RCS file: /cvs/libstdc++/libstdc++/bits/istream.tcc,v
retrieving revision 1.15
diff -u -r1.15 istream.tcc
--- istream.tcc	1999/08/12 03:54:16	1.15
+++ istream.tcc	1999/08/13 02:06:27
@@ -598,7 +598,7 @@
       do 
 	{
 	  __c = __is.rdbuf()->sbumpc();
-	  __testeof = __c == __eof;
+	  __testeof = __int_type(__c) == __eof;
 	  __testspace = isspace(__c); 
 	}
       while (!__testeof && __testspace);
Index: ./bits/sbuf_iter.h
===================================================================
RCS file: /cvs/libstdc++/libstdc++/bits/sbuf_iter.h,v
retrieving revision 1.15
diff -u -r1.15 sbuf_iter.h
--- sbuf_iter.h	1999/07/01 00:49:30	1.15
+++ sbuf_iter.h	1999/08/13 02:06:27
@@ -163,7 +163,7 @@
       { 
 	// The result of operator*() on an end of stream is undefined.
 	char_type __retval;
-	if (_M_istreambuf && _M_c > -2)
+	if (_M_istreambuf && _M_c != int_type(-2))
 	  __retval = _M_c;
 	else if (_M_istreambuf)
 	  __retval = traits_type::to_char_type(_M_istreambuf->sgetc()); 
Index: ./bits/std_istream.h
===================================================================
RCS file: /cvs/libstdc++/libstdc++/bits/std_istream.h,v
retrieving revision 1.32
diff -u -r1.32 std_istream.h
--- std_istream.h	1999/08/12 03:54:16	1.32
+++ std_istream.h	1999/08/13 02:06:28
@@ -511,7 +511,7 @@
 	      if (this->good())
 		{
 		  streamsize __num = this->rdbuf()->in_avail();
-		  if (__num != __eof)
+		  if (__num != streamsize(__eof))
 		    {
 		      __num = min(__num, __n);
 		      _M_gcount = this->rdbuf()->sgetn(__s, __num);
Index: ./src/Makefile.am
===================================================================
RCS file: /cvs/libstdc++/libstdc++/src/Makefile.am,v
retrieving revision 1.48
diff -u -r1.48 Makefile.am
--- Makefile.am	1999/08/12 20:04:00	1.48
+++ Makefile.am	1999/08/13 02:06:28
@@ -5,9 +5,10 @@
 # rules automake generates would be used.  We cannot use CXX to be used
 # in libtool since this would add -lstdc++ to the link line which of
 # course is impossible.
-CXXFLAGS = -g -D_GNU_SOURCE -fno-implicit-templates 
-#	   -fsquangle -fhonor-std -fnew-exceptions
-
+WERROR = -Werror
+# OTHER_CXXFLAGS = -fsquangle -fhonor-std -fnew-exceptions
+CXXFLAGS = -g -D_GNU_SOURCE -fno-implicit-templates \
+-Wall -W -Wwrite-strings $(WERROR) $(OTHER_CXXFLAGS)
 
 CXXLINK = $(LIBTOOL) --mode=link $(CC) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
 
Index: ./src/Makefile.in
===================================================================
RCS file: /cvs/libstdc++/libstdc++/src/Makefile.in,v
retrieving revision 1.56
diff -u -r1.56 Makefile.in
--- Makefile.in	1999/08/12 20:04:00	1.56
+++ Makefile.in	1999/08/13 02:06:28
@@ -84,8 +84,10 @@
 # rules automake generates would be used.  We cannot use CXX to be used
 # in libtool since this would add -lstdc++ to the link line which of
 # course is impossible.
-CXXFLAGS = -g -D_GNU_SOURCE -fno-implicit-templates 
-#	   -fsquangle -fhonor-std -fnew-exceptions
+WERROR = -Werror
+# OTHER_CXXFLAGS = -fsquangle -fhonor-std -fnew-exceptions
+CXXFLAGS = -g -D_GNU_SOURCE -fno-implicit-templates \
+-Wall -W -Wwrite-strings $(WERROR) $(OTHER_CXXFLAGS)
 
 CXXLINK = $(LIBTOOL) --mode=link $(CC) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
 

Michael.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]