c++/846: stream types non-const members

richarda@ixla.com.au richarda@ixla.com.au
Sun Nov 19 15:16:00 GMT 2000


>Number:         846
>Category:       c++
>Synopsis:       stream types non-const members
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 19 15:16:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Richard Andrews
>Release:        libstdc++-2.90.8
>Organization:
>Environment:
i686-pc-linux-gnu (RH6.2 gcc2.95.2)
>Description:
libstdc++-2.90.8

is_open() member of stream types is const in some 
parts of the hierarchy but not others.

When inheriting from fstream, is_open() is no longer a 
const member.

It is obvious that it is an error in some places as 
is_open() merely calls another const member.
ie. (bits/std_fstream.h)

      bool 
      is_open(void) { return rdbuf()->is_open(); }

>How-To-Repeat:
class A : private fstream
{
public:
	bool isOpen() const
	{ 
	  return is_open() 
	};
}
>Fix:
ensure is_open() is a const member of all stream types.
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the Gcc-bugs mailing list