public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15128] New: Windows seekp/seekg bug
@ 2004-04-25 13:31 g_50 at hotmail dot com
  2004-04-25 14:34 ` [Bug c++/15128] " pinskia at gcc dot gnu dot org
  2004-04-25 22:20 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: g_50 at hotmail dot com @ 2004-04-25 13:31 UTC (permalink / raw)
  To: gcc-bugs

The gcc -v output is at the bottom of this. The following small testcase
produces incorrect file output as far back as gcc 3.2 <mingw special 20020817-1>.
Gcc 3.2 included in Mandrake Linux 9.1 produced the expected output in the file.
The following code is compiled on WinXP Pro using: g++ -mno-cygwin database.cpp
-odatabase

//database.cpp
#include <fstream>
#include <iostream>

using std::ios;
typedef unsigned short u_short;

bool NumberAlreadyExists ( std::fstream &rRead, u_short number )
{
    bool exist = false;
    u_short temp_number;
    rRead.seekg( 0 ); //go to start of file
    while ( rRead >> temp_number )
    {
        if ( temp_number == number )
                exist = true;
    }
    if ( rRead.eof() )
    {
        rRead.clear();
        rRead.seekg(0); //go to beginning
    }    
    return exist;
}
        
int main( )
{
    std::fstream data ("data.txt",ios::in|ios::out|ios::trunc);
    if (!data) return 1;
    u_short four_digit_number;    
    char continue_loop = 'y';
    
    while ( continue_loop == 'y' )
    {
        std::cout <<"Enter a positive 4 digit number: ";
        std::cin >> four_digit_number;
        
        if ( NumberAlreadyExists ( data,  four_digit_number ) )
        {
           std::cout << "\aNumber Already Exists!!\n";
           continue;
        }        
        data.seekp (0, std::ios::end ); // go to end of file    
        data << four_digit_number << std::endl;       
        std::cout << "Continue ...?(y/n): ";
        std::cin>>continue_loop;
    }
    data.close();
    return 0;
} 
/*      
Output:
Enter a positive 4 digit number: 1000
Continue ...?(y/n): y
Enter a positive 4 digit number: 1001
Continue ...?(y/n): n

Contents of data.txt:
11000
1001
*/      


Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/specs
Configured with: /GCC/gcc-3.3.1-3/configure --with-gcc --with-gnu-ld --with-gnu-
as --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexe
cdir=/usr/sbin --mandir=/usr/share/man --infodir=/usr/share/info --enable-langua
ges=c,ada,c++,f77,pascal,java,objc --enable-libgcj --enable-threads=posix --with
-system-zlib --enable-nls --without-included-gettext --enable-interpreter --enab
le-sjlj-exceptions --disable-version-specific-runtime-libs --enable-shared --dis
able-win32-registry --enable-java-gc=boehm --disable-hash-synchronization --verb
ose --target=i686-pc-cygwin --host=i686-pc-cygwin --build=i686-pc-cygwin
Thread model: posix
gcc version 3.3.1 (cygming special)

-- 
           Summary: Windows seekp/seekg bug
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: g_50 at hotmail dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-cygwin
  GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15128


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/15128] Windows seekp/seekg bug
  2004-04-25 13:31 [Bug c++/15128] New: Windows seekp/seekg bug g_50 at hotmail dot com
@ 2004-04-25 14:34 ` pinskia at gcc dot gnu dot org
  2004-04-25 22:20 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-25 14:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-25 13:59 -------
Can you try a newer compiler, the compiler which you are using is a prelease from your vender 
(cygwin)?
Can you also next time report it first to cygwin as this could be a bug in cygwin's runtime. (or mingw if 
you are using that)?

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15128


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/15128] Windows seekp/seekg bug
  2004-04-25 13:31 [Bug c++/15128] New: Windows seekp/seekg bug g_50 at hotmail dot com
  2004-04-25 14:34 ` [Bug c++/15128] " pinskia at gcc dot gnu dot org
@ 2004-04-25 22:20 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-25 22:20 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-25 20:39 -------
This is a dup of bug 13333.

*** This bug has been marked as a duplicate of 13333 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15128


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-04-25 20:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-25 13:31 [Bug c++/15128] New: Windows seekp/seekg bug g_50 at hotmail dot com
2004-04-25 14:34 ` [Bug c++/15128] " pinskia at gcc dot gnu dot org
2004-04-25 22:20 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).