You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by "Martin Sebor (JIRA)" <ji...@apache.org> on 2006/03/04 01:40:39 UTC

[jira] Created: (STDCXX-161) filebuf::sgetn() fails after sputn() in stdio mode

filebuf::sgetn() fails after sputn() in stdio mode
--------------------------------------------------

         Key: STDCXX-161
         URL: http://issues.apache.org/jira/browse/STDCXX-161
     Project: C++ Standard Library
        Type: Bug
  Components: 27. Input/Output  
    Versions: 4.1.3    
 Environment: all
    Reporter: Martin Sebor
 Assigned to: Martin Sebor 
    Priority: Critical
     Fix For: 4.1.4


The program below fails at runtime (std::ios::stdio is an extension of this implementation that forces the filebuf to use the stdio facilities for I/O instead of OS native calls).

$ cat t.cpp && gmake t && ./t
#include <fstream>
#include <cassert>

int main ()
{
    std::filebuf fb;

    assert (0 != fb.open ("testfile.text", std::ios::out));
    assert (6 == fb.sputn ("ABCDEF", 6));
    assert (0 != fb.close ());

    assert (0 != fb.open ("testfile.text",
                          std::ios::in | std::ios::out | std::ios::stdio));

    assert (3 == fb.sputn ("abc", 3));
    assert (-1 != fb.pubsync ());

    char buf [3] = "";
    assert (3 == fb.sgetn (buf, sizeof buf));
    assert (0 == std::filebuf::traits_type::compare ("DEF", buf, 3));
}
aCC -c -I/build/sebor/dev/stdlib/include/ansi -I/usr/include  -D_RWSTDDEBUG   -mt -D_RWSTD_USE_CONFIG -I/build/sebor/aCC-3.63-15s/include -I/build/sebor/dev/stdlib/include -I/build/sebor/dev/stdlib/../rwtest -I/build/sebor/dev/stdlib/../rwtest/include -I/build/sebor/dev/stdlib/tests/include  -Aa +nostl  -g +d  +w +W392 +W655 +W684 +W818 +W819 +W849  t.cpp
aCC t.o -o t -L/build/sebor/aCC-3.63-15s/rwtest -lrwtest15s -Aa +nostl -Wl,+s -Wl,+vnocompatwarnings -L/build/sebor/aCC-3.63-15s/lib   -mt -L/build/sebor/aCC-3.63-15s/lib -lstd15s   -lm
Assertion failed: 0 == std::filebuf::traits_type::compare ("DEF", buf, 3), file t.cpp, line 20
ABORT instruction (core dumped)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Resolved: (STDCXX-161) filebuf::sgetn() fails after sputn() in stdio mode

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/STDCXX-161?page=all ]
     
Martin Sebor resolved STDCXX-161:
---------------------------------

    Resolution: Fixed

Fixed with the referenced change.

> filebuf::sgetn() fails after sputn() in stdio mode
> --------------------------------------------------
>
>          Key: STDCXX-161
>          URL: http://issues.apache.org/jira/browse/STDCXX-161
>      Project: C++ Standard Library
>         Type: Bug
>   Components: 27. Input/Output
>     Versions: 4.1.3
>  Environment: all
>     Reporter: Martin Sebor
>     Assignee: Martin Sebor
>     Priority: Critical
>      Fix For: 4.1.4

>
> The program below fails at runtime (std::ios::stdio is an extension of this implementation that forces the filebuf to use the stdio facilities for I/O instead of OS native calls).
> $ cat t.cpp && gmake t && ./t
> #include <fstream>
> #include <cassert>
> int main ()
> {
>     std::filebuf fb;
>     assert (0 != fb.open ("testfile.text", std::ios::out));
>     assert (6 == fb.sputn ("ABCDEF", 6));
>     assert (0 != fb.close ());
>     assert (0 != fb.open ("testfile.text",
>                           std::ios::in | std::ios::out | std::ios::stdio));
>     assert (3 == fb.sputn ("abc", 3));
>     assert (-1 != fb.pubsync ());
>     char buf [3] = "";
>     assert (3 == fb.sgetn (buf, sizeof buf));
>     assert (0 == std::filebuf::traits_type::compare ("DEF", buf, 3));
> }
> aCC -c -I/build/sebor/dev/stdlib/include/ansi -I/usr/include  -D_RWSTDDEBUG   -mt -D_RWSTD_USE_CONFIG -I/build/sebor/aCC-3.63-15s/include -I/build/sebor/dev/stdlib/include -I/build/sebor/dev/stdlib/../rwtest -I/build/sebor/dev/stdlib/../rwtest/include -I/build/sebor/dev/stdlib/tests/include  -Aa +nostl  -g +d  +w +W392 +W655 +W684 +W818 +W819 +W849  t.cpp
> aCC t.o -o t -L/build/sebor/aCC-3.63-15s/rwtest -lrwtest15s -Aa +nostl -Wl,+s -Wl,+vnocompatwarnings -L/build/sebor/aCC-3.63-15s/lib   -mt -L/build/sebor/aCC-3.63-15s/lib -lstd15s   -lm
> Assertion failed: 0 == std::filebuf::traits_type::compare ("DEF", buf, 3), file t.cpp, line 20
> ABORT instruction (core dumped)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira