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/06/28 22:45:33 UTC

[jira] Created: (STDCXX-241) std::istream::seekg problem (LWG issue 136)

std::istream::seekg problem (LWG issue 136)
-------------------------------------------

         Key: STDCXX-241
         URL: http://issues.apache.org/jira/browse/STDCXX-241
     Project: C++ Standard Library
        Type: Bug

  Components: 27. Input/Output  
    Versions: 4.1.2, 4.1.3    
 Environment: all
    Reporter: Martin Sebor


Moved from the Rogue Wave bug tracking database:

Class/File: 
Fix Priority: Must Fix
Long Description: 
  *** Nov 10 1999 9:33PM *** sebor ***

Problem: seekg - problem

see seek2.cpp:

The ANSI/ISO-C++ document(ISO/IEC 14882:1998(E)) states about the effects of seekg:

ANSI> Effects: If fail() != true, executes rdbuf()í>pubseekpos( pos).

(The RW-Implementation instead executes rdbuf()->pubseekpos(pos, ios_base::in);)
pubseekpos calls seekpos which is declared:

pos_type seekpos(pos_type sp, ios_base::openmode which
                  = ios_base::in | ios_base::out);

since the 2nd Argument (which) is not given in the above call of pubseekpos
the value of the which-Argument is the default value ios_base::in | ios_base::out.
seekpos should alter both the position in the input and the output sequence in this case.
The RW-Implementation alters only the position in the input-sequence.

Though the RW-implementation seems to be intuitivly right, it is formally
not conforming.
I think RogueWave should support the lwg issue No 136 described in
http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-issues.html#136

TEST CASE:

#include <string>
#include <sstream>
#include <iostream>

using namespace std;

typedef basic_stringbuf<char, char_traits<char>, allocator<char> > buffer;
typedef basic_istream<char, char_traits<char> > input_stream;
typedef char_traits <char> traits;
typedef char_traits<char>::pos_type pos_type;


#define VERIFY(p1,p2) verify(p1,p2,__LINE__)

template <class T> void verify (T p1, T p2, int line)
{
  if(p1 != p2) {
    cerr << "line " << line << ": " << p1 << " should be " 
         << p2 << '\n';
  }
}

template <> void verify (string p1, string p2, int line)
{
  if(p1 != p2) {
    cerr << "line " << line << ": \"" << p1 << "\" should be \"" 
         << p2 << "\" \n";
  }
}



int main()
{
  const string expstr ("Rogue Wave");
  buffer  buf (expstr, ios_base::in | ios_base::out);
  typedef basic_iostream<char, char_traits<char> > iostrm; 
      
  iostrm  iostobj(&buf);
  char s[80];
 
  VERIFY ((void *)iostobj.rdbuf(),(void *)&buf);
  VERIFY (iostobj.gcount(),streamsize(0));
          
  iostobj >> s;
  VERIFY (string(s), string("Rogue"));
  iostobj.get (s, sizeof s);
  VERIFY (string(s), string(" Wave"));
  iostobj.clear ();
  iostobj.seekg (0, ios::end);
  iostobj.write (" Software", 9);
  iostobj.seekp (0);
  iostobj.get (s, sizeof s);
  iostobj.clear ();
  VERIFY (string(s), string("Rogue Wave Software"));
}
CC -c -mt -D_RWSTD_USE_CONFIG -I/amd/devco/sebor/dev/stdlib/include -I/build/seb
or/sunpro-5.8.j1-12d/include -I/amd/devco/sebor/dev/stdlib/examples/include  -li
brary=%none -O  +w  t.cpp
CC t.o -o t -library=%none -L/build/sebor/sunpro-5.8.j1-12d/lib  -mt  -L/build/s
ebor/sunpro-5.8.j1-12d/lib -lstd12d   -lm
line 55: " Software" should be "Rogue Wave Software" 


-- 
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] Commented: (STDCXX-241) [LWG #136] std::istream::seekg problem

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12468049 ] 

Martin Sebor commented on STDCXX-241:
-------------------------------------

Since the issue's resolution has been accepted this is now a conformance bug (or it will become one as soon as the Working Paper turns into the new C++ Standard).

> [LWG #136] std::istream::seekg problem
> --------------------------------------
>
>                 Key: STDCXX-241
>                 URL: https://issues.apache.org/jira/browse/STDCXX-241
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 27. Input/Output
>    Affects Versions: 4.1.3, 4.1.2
>         Environment: all
>            Reporter: Martin Sebor
>
> Moved from the Rogue Wave bug tracking database:
> Class/File: 
> Fix Priority: Must Fix
> Long Description: 
>   *** Nov 10 1999 9:33PM *** sebor ***
> Problem: seekg - problem
> see seek2.cpp:
> The ANSI/ISO-C++ document(ISO/IEC 14882:1998(E)) states about the effects of seekg:
> ANSI> Effects: If fail() != true, executes rdbuf()í>pubseekpos( pos).
> (The RW-Implementation instead executes rdbuf()->pubseekpos(pos, ios_base::in);)
> pubseekpos calls seekpos which is declared:
> pos_type seekpos(pos_type sp, ios_base::openmode which
>                   = ios_base::in | ios_base::out);
> since the 2nd Argument (which) is not given in the above call of pubseekpos
> the value of the which-Argument is the default value ios_base::in | ios_base::out.
> seekpos should alter both the position in the input and the output sequence in this case.
> The RW-Implementation alters only the position in the input-sequence.
> Though the RW-implementation seems to be intuitivly right, it is formally
> not conforming.
> I think RogueWave should support the lwg issue No 136 described in
> http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-issues.html#136
> TEST CASE:
> #include <string>
> #include <sstream>
> #include <iostream>
> using namespace std;
> typedef basic_stringbuf<char, char_traits<char>, allocator<char> > buffer;
> typedef basic_istream<char, char_traits<char> > input_stream;
> typedef char_traits <char> traits;
> typedef char_traits<char>::pos_type pos_type;
> #define VERIFY(p1,p2) verify(p1,p2,__LINE__)
> template <class T> void verify (T p1, T p2, int line)
> {
>   if(p1 != p2) {
>     cerr << "line " << line << ": " << p1 << " should be " 
>          << p2 << '\n';
>   }
> }
> template <> void verify (string p1, string p2, int line)
> {
>   if(p1 != p2) {
>     cerr << "line " << line << ": \"" << p1 << "\" should be \"" 
>          << p2 << "\" \n";
>   }
> }
> int main()
> {
>   const string expstr ("Rogue Wave");
>   buffer  buf (expstr, ios_base::in | ios_base::out);
>   typedef basic_iostream<char, char_traits<char> > iostrm; 
>       
>   iostrm  iostobj(&buf);
>   char s[80];
>  
>   VERIFY ((void *)iostobj.rdbuf(),(void *)&buf);
>   VERIFY (iostobj.gcount(),streamsize(0));
>           
>   iostobj >> s;
>   VERIFY (string(s), string("Rogue"));
>   iostobj.get (s, sizeof s);
>   VERIFY (string(s), string(" Wave"));
>   iostobj.clear ();
>   iostobj.seekg (0, ios::end);
>   iostobj.write (" Software", 9);
>   iostobj.seekp (0);
>   iostobj.get (s, sizeof s);
>   iostobj.clear ();
>   VERIFY (string(s), string("Rogue Wave Software"));
> }
> CC -c -mt -D_RWSTD_USE_CONFIG -I/amd/devco/sebor/dev/stdlib/include -I/build/seb
> or/sunpro-5.8.j1-12d/include -I/amd/devco/sebor/dev/stdlib/examples/include  -li
> brary=%none -O  +w  t.cpp
> CC t.o -o t -library=%none -L/build/sebor/sunpro-5.8.j1-12d/lib  -mt  -L/build/s
> ebor/sunpro-5.8.j1-12d/lib -lstd12d   -lm
> line 55: " Software" should be "Rogue Wave Software" 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (STDCXX-241) [LWG #136] std::istream::seekg problem

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-241?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Sebor updated STDCXX-241:
--------------------------------

    Summary: [LWG #136] std::istream::seekg problem  (was: std::istream::seekg problem (LWG issue 136))

Used the [LWG NN] convention in Summary line to refer to Library Working Group issue number 136: http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#136

> [LWG #136] std::istream::seekg problem
> --------------------------------------
>
>                 Key: STDCXX-241
>                 URL: https://issues.apache.org/jira/browse/STDCXX-241
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 27. Input/Output
>    Affects Versions: 4.1.3, 4.1.2
>         Environment: all
>            Reporter: Martin Sebor
>
> Moved from the Rogue Wave bug tracking database:
> Class/File: 
> Fix Priority: Must Fix
> Long Description: 
>   *** Nov 10 1999 9:33PM *** sebor ***
> Problem: seekg - problem
> see seek2.cpp:
> The ANSI/ISO-C++ document(ISO/IEC 14882:1998(E)) states about the effects of seekg:
> ANSI> Effects: If fail() != true, executes rdbuf()í>pubseekpos( pos).
> (The RW-Implementation instead executes rdbuf()->pubseekpos(pos, ios_base::in);)
> pubseekpos calls seekpos which is declared:
> pos_type seekpos(pos_type sp, ios_base::openmode which
>                   = ios_base::in | ios_base::out);
> since the 2nd Argument (which) is not given in the above call of pubseekpos
> the value of the which-Argument is the default value ios_base::in | ios_base::out.
> seekpos should alter both the position in the input and the output sequence in this case.
> The RW-Implementation alters only the position in the input-sequence.
> Though the RW-implementation seems to be intuitivly right, it is formally
> not conforming.
> I think RogueWave should support the lwg issue No 136 described in
> http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-issues.html#136
> TEST CASE:
> #include <string>
> #include <sstream>
> #include <iostream>
> using namespace std;
> typedef basic_stringbuf<char, char_traits<char>, allocator<char> > buffer;
> typedef basic_istream<char, char_traits<char> > input_stream;
> typedef char_traits <char> traits;
> typedef char_traits<char>::pos_type pos_type;
> #define VERIFY(p1,p2) verify(p1,p2,__LINE__)
> template <class T> void verify (T p1, T p2, int line)
> {
>   if(p1 != p2) {
>     cerr << "line " << line << ": " << p1 << " should be " 
>          << p2 << '\n';
>   }
> }
> template <> void verify (string p1, string p2, int line)
> {
>   if(p1 != p2) {
>     cerr << "line " << line << ": \"" << p1 << "\" should be \"" 
>          << p2 << "\" \n";
>   }
> }
> int main()
> {
>   const string expstr ("Rogue Wave");
>   buffer  buf (expstr, ios_base::in | ios_base::out);
>   typedef basic_iostream<char, char_traits<char> > iostrm; 
>       
>   iostrm  iostobj(&buf);
>   char s[80];
>  
>   VERIFY ((void *)iostobj.rdbuf(),(void *)&buf);
>   VERIFY (iostobj.gcount(),streamsize(0));
>           
>   iostobj >> s;
>   VERIFY (string(s), string("Rogue"));
>   iostobj.get (s, sizeof s);
>   VERIFY (string(s), string(" Wave"));
>   iostobj.clear ();
>   iostobj.seekg (0, ios::end);
>   iostobj.write (" Software", 9);
>   iostobj.seekp (0);
>   iostobj.get (s, sizeof s);
>   iostobj.clear ();
>   VERIFY (string(s), string("Rogue Wave Software"));
> }
> CC -c -mt -D_RWSTD_USE_CONFIG -I/amd/devco/sebor/dev/stdlib/include -I/build/seb
> or/sunpro-5.8.j1-12d/include -I/amd/devco/sebor/dev/stdlib/examples/include  -li
> brary=%none -O  +w  t.cpp
> CC t.o -o t -library=%none -L/build/sebor/sunpro-5.8.j1-12d/lib  -mt  -L/build/s
> ebor/sunpro-5.8.j1-12d/lib -lstd12d   -lm
> line 55: " Software" should be "Rogue Wave Software" 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.