You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Farid Zaripov <Fa...@epam.com> on 2007/07/12 20:46:37 UTC

MyStreambuf class is incomplete

  The throw_when_ mebmer of the MyStreambuf class (rw_streambuf.h line
183) is
not initialized at the moment in class ctor's (only zero'ed), but used
in
MyStreambuf::test() (lines 472, 483). I suppose that this class designed
to initialize
throw_when_ within test functions. But for now the all iostream tests
doesn't do it. 
Maybe we just remove this mebmer at all? The patch is ready :)

  ChangeLog:
  * rw_streambuf.h: Removed MyStreambuf::throw_when_ member as unused.

Index: rw_streambuf.h
===================================================================
--- rw_streambuf.h	(revision 555508)
+++ rw_streambuf.h	(working copy)
@@ -180,7 +180,6 @@
 
     int        fail_when_;       // call number on which to fail
 
-    int        throw_when_ [11]; // call number on which to throw for
each func
     int        allthrows_;       // total number of thrown exceptions
 
     // max size of the pending input sequence
@@ -219,9 +218,6 @@
     // reset the member function call counters
     std::memset (ncalls_, 0, sizeof ncalls_);
 
-    // reset the member function throw counters
-    std::memset (throw_when_, 0, sizeof throw_when_);
-
     // allocate a (possibly wide) character buffer for output
     buf_ = new charT [bufsize_];
 
@@ -252,9 +248,6 @@
     // reset the member function call counters
     std::memset (ncalls_, 0, sizeof ncalls_);
 
-    // reset the member function throw counters
-    std::memset (throw_when_, 0, sizeof throw_when_);
-
     // as a convenience, if `bufsize == -1' compute the size
     // from the length of `buf'
     if (std::streamsize (-1) == bufsize_)
@@ -469,7 +462,7 @@
     // if the call counter is equal to the `fail_when_' watermark
     // and `shich' is set in the `throw_set_' bitmask, throw an
     // exception with the value of the member id
-    if (callno == throw_when_ [inx] && throw_set_ & which) {
+    if (callno == fail_when_ && throw_set_ & which) {
         self->threw_ = which;
         self->allthrows_++;
 
@@ -480,7 +473,7 @@
 
 #else   // if defined (_RWSTD_NO_EXCEPTIONS)
 
-    if (callno == throw_when_ [inx] && throw_set_ & which) {
+    if (callno == fail_when_ && throw_set_ & which) {
         self->threw_ = which;
         return false;
     }

 
Farid.

Re: MyStreambuf class is incomplete

Posted by Martin Sebor <se...@roguewave.com>.
Farid Zaripov wrote:
>> -----Original Message-----
>> From: Martin Sebor [mailto:msebor@gmail.com] On Behalf Of Martin Sebor
>> Sent: Wednesday, July 18, 2007 7:16 AM
>> To: stdcxx-dev@incubator.apache.org
>> Subject: Re: MyStreambuf class is incomplete
>>
>> Farid Zaripov wrote:
>>>   The throw_when_ mebmer of the MyStreambuf class 
>> (rw_streambuf.h line
>>> 183) is
>>> not initialized at the moment in class ctor's (only 
>> zero'ed), but used 
>>> in
>>> MyStreambuf::test() (lines 472, 483). I suppose that this class 
>>> designed to initialize throw_when_ within test functions. 
>> But for now 
>>> the all iostream tests doesn't do it.
>>> Maybe we just remove this mebmer at all? The patch is ready :)
>> I'm not dead set against removing it but if it ain't broke...?
>> Is it actually causing problems or are you just cleaning things up?
> 
>   It causing problems because the tests are uses fail_when parameter to
> set when
> MyStreambuf should to throw, but MyStreambuf throws only if throw_when_
> [inx] == callno.
> So we should to apply my patch (remove throw_when_ and throw when
> fail_when_ == callno,
> or modify all tests to set throw_when_[] array.

I think I remember now. IIRC, the intent behind the throw_when_ array
is to make it possible to induce exceptions only from specific functions
without accidentally making some other function called from the first
throw instead. The purpose of the fail_when member is to make the tested
function fail after that many calls. So I think we need to keep the
array and fix the tests, otherwise we might cause failures because of
exceptions being thrown by the wrong functions. Don't you think?

Martin

RE: MyStreambuf class is incomplete

Posted by Farid Zaripov <Fa...@epam.com>.
> -----Original Message-----
> From: Martin Sebor [mailto:msebor@gmail.com] On Behalf Of Martin Sebor
> Sent: Wednesday, July 18, 2007 7:16 AM
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: MyStreambuf class is incomplete
> 
> Farid Zaripov wrote:
> >   The throw_when_ mebmer of the MyStreambuf class 
> (rw_streambuf.h line
> > 183) is
> > not initialized at the moment in class ctor's (only 
> zero'ed), but used 
> > in
> > MyStreambuf::test() (lines 472, 483). I suppose that this class 
> > designed to initialize throw_when_ within test functions. 
> But for now 
> > the all iostream tests doesn't do it.
> > Maybe we just remove this mebmer at all? The patch is ready :)
> 
> I'm not dead set against removing it but if it ain't broke...?
> Is it actually causing problems or are you just cleaning things up?

  It causing problems because the tests are uses fail_when parameter to
set when
MyStreambuf should to throw, but MyStreambuf throws only if throw_when_
[inx] == callno.
So we should to apply my patch (remove throw_when_ and throw when
fail_when_ == callno,
or modify all tests to set throw_when_[] array.

Farid.

Re: MyStreambuf class is incomplete

Posted by Martin Sebor <se...@roguewave.com>.
Farid Zaripov wrote:
>   The throw_when_ mebmer of the MyStreambuf class (rw_streambuf.h line
> 183) is
> not initialized at the moment in class ctor's (only zero'ed), but used
> in
> MyStreambuf::test() (lines 472, 483). I suppose that this class designed
> to initialize
> throw_when_ within test functions. But for now the all iostream tests
> doesn't do it. 
> Maybe we just remove this mebmer at all? The patch is ready :)

I'm not dead set against removing it but if it ain't broke...?
Is it actually causing problems or are you just cleaning things
up?

Martin

> 
>   ChangeLog:
>   * rw_streambuf.h: Removed MyStreambuf::throw_when_ member as unused.
> 
> Index: rw_streambuf.h
> ===================================================================
> --- rw_streambuf.h	(revision 555508)
> +++ rw_streambuf.h	(working copy)
> @@ -180,7 +180,6 @@
>  
>      int        fail_when_;       // call number on which to fail
>  
> -    int        throw_when_ [11]; // call number on which to throw for
> each func
>      int        allthrows_;       // total number of thrown exceptions
>  
>      // max size of the pending input sequence
> @@ -219,9 +218,6 @@
>      // reset the member function call counters
>      std::memset (ncalls_, 0, sizeof ncalls_);
>  
> -    // reset the member function throw counters
> -    std::memset (throw_when_, 0, sizeof throw_when_);
> -
>      // allocate a (possibly wide) character buffer for output
>      buf_ = new charT [bufsize_];
>  
> @@ -252,9 +248,6 @@
>      // reset the member function call counters
>      std::memset (ncalls_, 0, sizeof ncalls_);
>  
> -    // reset the member function throw counters
> -    std::memset (throw_when_, 0, sizeof throw_when_);
> -
>      // as a convenience, if `bufsize == -1' compute the size
>      // from the length of `buf'
>      if (std::streamsize (-1) == bufsize_)
> @@ -469,7 +462,7 @@
>      // if the call counter is equal to the `fail_when_' watermark
>      // and `shich' is set in the `throw_set_' bitmask, throw an
>      // exception with the value of the member id
> -    if (callno == throw_when_ [inx] && throw_set_ & which) {
> +    if (callno == fail_when_ && throw_set_ & which) {
>          self->threw_ = which;
>          self->allthrows_++;
>  
> @@ -480,7 +473,7 @@
>  
>  #else   // if defined (_RWSTD_NO_EXCEPTIONS)
>  
> -    if (callno == throw_when_ [inx] && throw_set_ & which) {
> +    if (callno == fail_when_ && throw_set_ & which) {
>          self->threw_ = which;
>          return false;
>      }
> 
>  
> Farid.
>