This is the mail archive of the 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]
Other format: [Raw text]

RE: [Patch] Fix libstdc++/9507


> >>P.S. The original testcase is really involved compared to the
> >>underlying issue and I would rather prefer not adding it.
> >>
> >It might be easier to test this by deriving a class from std::filebuf
> >and override seekoff to always return pos_type(off_type(-1)).
> >
> Yes, thanks, like this:
> class c_fbuf : public basic_filebuf<char>
> {
>   pos_type
>   seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode 
> __mode)
>   {
>     return pos_type(off_type(-1));
>   }
> };
> int main()
> {
>   c_fbuf fbuf;
>   c_fbuf* r = static_cast<c_fbuf*>("xxx", ios_base::out | 
> ios_base::ate));
>   assert(!fbuf.is_open());
>   assert(r == NULL);
> }

On second thought, this probably isn't correct, I don't think open
is required to call seekoff, it might for example call fseek directly.

> however, I didn't notice that all the necessary includes were already
> present in and another testcase used the very same
> functions. I'm going to post a revised patch including your original 
> testcase.

If you are changing, you might want to remove the
exit(0); at the end of test04 - it seems that test05 is never run :-)


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