This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug libstdc++/72830] New: istream::seekg should not reset eofbit if -std=c++98


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72830

            Bug ID: 72830
           Summary: istream::seekg should not reset eofbit if -std=c++98
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alexhenrie24 at gmail dot com
  Target Milestone: ---

Created attachment 39070
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39070&action=edit
Test program that demonstrates the problem

According to N3168 [1], as recently as 2010 the C++ standards did not permit
istream::seekg to reset istream::eof. When the change to the standard was
approved, libstdc++ started using the new behavior, even for programs compiled
with -std=c++98. This caused the bioinformatics program GERMLINE [2] to break.
In PEDIndividualsExtractor.cpp [3] we see:

void PEDIndividualsExtractor::loadInput()
{
    ...

        while (!stream.eof() )
        {
                getIndividuals();
                stream.seekg(numberOfMarkers*4 + 1,ios::cur);
        }

    ...
}

void PEDIndividualsExtractor::getIndividuals()
{
        string discard, ID, famID;
        stream >> famID >> ID >> discard >> discard >> discard >> discard;
        if(!stream.good()) return;

        ...
}

This code stopped working sometime between GCC 4.4.5 / libstdc++ 6.0.13 and GCC
4.6.3 / libstdc++ 6.0.16. With the change to libstdc++, stream.eof() is always
false, so loadInput() goes into an infinite loop. A simple test program is
attached.

I realize that I could petition the GERMLINE authors to change the loop
condition (and I eventually will), but the fact that you can't get the old
behavior even with -std=c++98 is a bug in GCC.

[1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3168.htm
[2] http://www.cs.columbia.edu/~gusev/germline/
[3] http://www.cs.columbia.edu/~gusev/germline/germline-1-5-1.tar.gz

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