This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


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

Problems overriding underflow() and overflow() in derived streambuf.


Hi folks,

I'm having problems getting the following code to compile in g++ from CVS
(retrieved around noon today)... This build from CVS g++ just fine a few
months back...  I think the problem is two-fold... The most obvious problem
is that the return type is (as far as I know) supposed to be int... After chasing
back through all the templates, the char_traits<char>::int_type is defined as
unsigned long... (There is a comment there explaining why it was defined this
way,  but it didn't make any sense to me... also this file doesn't appear to have
been changed since initially being checked into CVS in October...

In hopes of resolving the problem with the minimal hassel, I changed the
header file to define char_traits<char>::int_type as int, and was suprised to
get the SAME ERROR (I haven't tried that since last week, but I'm guessing
it hasn't changed much since then...)

Anyway, without further adue, the minimal test case:

=== BEGIN CODE ===
#include <iostream.h>

class MyBuf : public streambuf
{
	typedef streambuf inherited;
	public:
		virtual int underflow() { return inherited::underflow();}
		virtual int overflow() { return inherited::overflow();}
};

int main(void)
{
	// Create One
	MyBuf buf;

	return 0;
}
==== END CODE ====

the error message:

=== BEGIN g++ OUTPUT ===
[loren@frankenbox src]$ /usr/local/bin/g++ -o gcc_testcase gcc_testcase.cpp
gcc_testcase.cpp:8: conflicting return type specified for `virtual int 
   MyBuf::underflow()'
/usr/local/include/g++-v3/bits/std_streambuf.h:455:   overriding `typename 
   _Traits::int_type std::basic_streambuf<_CharT, _Traits>::underflow() [with 
   _CharT = char, _Traits = std::char_traits<char>]'
[loren@frankenbox src]$
==== END g++ OUTPUT ====

Any help appreciated...

Best Regards,

-Loren Osborn
Programmer, Reflexive Entertainment, Inc.
http://www.reflexive.net


...................................
Great news! Get free KNXmail here!
http://www.knx1070.com


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