[PATCH] streambuf.h warning fix

Jakub Jelinek jakub@redhat.com
Thu Apr 20 03:34:00 GMT 2000


Hi!

Compiling anything that includes streambuf.h warns on sparc64 about the
cast to pointer from integer of different size.
It would be best if (void*)(intptr_t) could be used, but as we cannot rely
on that type being defined before streambuf.h, IMHO -1L will suffice for
most cases.
Ok to commit?

2000-04-20  Jakub Jelinek  <jakub@redhat.com>

	* streambuf.h (ios::operator void*): Use long -1 constant casted
	to void * to avoid warnings.

--- libio/streambuf.h.jj	Wed Dec 22 09:51:44 1999
+++ libio/streambuf.h	Thu Apr 20 12:18:41 2000
@@ -219,7 +219,9 @@ class ios : public _ios_fields {
     int fail() const { return _state & (ios::badbit|ios::failbit); }
     int bad() const { return _state & ios::badbit; }
     iostate rdstate() const { return _state; }
-    operator void*() const { return fail() ? (void*)0 : (void*)(-1); }
+    /* Should use (intptr_t)(-1) instead of (-1L) below, but intptr_t
+       is not probed.  */
+    operator void*() const { return fail() ? (void*)0 : (void*)(-1L); }
     int operator!() const { return fail(); }
     iostate exceptions() const { return _exceptions; }
     void exceptions(iostate enable) {

	Jakub


More information about the Gcc-patches mailing list