This is the mail archive of the gcc-prs@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]

libstdc++/4523: regression: struct in namespace containing an ifstream defined outside



>Number:         4523
>Category:       libstdc++
>Synopsis:       regression: struct in namespace containing an ifstream defined outside
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 10 09:26:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Pal Benko
>Release:        3.0.1
>Organization:
>Environment:
SuSE 7.1, linux 2.4.6, i686
>Description:
Perhaps this is a c++ bug.  Compiling the following:

---------------------------------------------------->8
#include <fstream>

namespace w
{
  struct a;
}

struct w::a
{
  std::ifstream i_;
};
----------------------------------------------------->8

Gives the following error messages:

arta:~/c/proba$ /gml/shared/gcc-3.0.1/bin/g++ -c fstream_test.cc 
/gml/shared/gcc-3.0.1/include/g++-v3/bits/std_streambuf.h: In instantiation of `std::basic_streambuf<char, std::char_traits<char> >':
/gml/shared/gcc-3.0.1/include/g++-v3/bits/std_fstream.h:245:   instantiated from `std::basic_filebuf<char, std::char_traits<char> >'
/gml/shared/gcc-3.0.1/include/g++-v3/bits/std_fstream.h:245:   instantiated from `std::basic_ifstream<char, std::char_traits<char> >'
fstream_test.cc:10:   instantiated from here
/gml/shared/gcc-3.0.1/include/g++-v3/bits/std_streambuf.h:77: `__copy_streambufs'
   was not declared in this scope

2.95.3 compiles this OK.  Precompiling this with 2.95.3
and compiling the resulting code with 3.0.1 gives

arta:~/c/proba$ /gml/shared/gcc-2.95.3/bin/g++ -E -o fstream_test.ii fstream_test.cc 
arta:~/c/proba$ /gml/shared/gcc-3.0.1/bin/g++ -c fstream_test.ii
fstream_test.cc:10: ISO C++ forbids declaration of `ifstream' with no type
fstream_test.cc:10: invalid use of `::'
fstream_test.cc:10: parse error before `;' token

If the "std::" is removed, then compilation works.

Precompiling with 3.0.1 and compiling with 2.95.3 gives lots of errors,
but obviously because of libstdc++-3.



Workaround:

--------------------------------------------------->8
#include <fstream>

namespace w
{
  struct a
  {
    mutable std::ifstream i_;
  };
}
----------------------------------------------------->8
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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