public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/16251] New: bogus default constructor for std::basic_iostream
@ 2004-06-28 19:48 ralfixx at gmx dot de
2004-07-05 12:49 ` [Bug libstdc++/16251] " ralfixx at gmx dot de
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: ralfixx at gmx dot de @ 2004-06-28 19:48 UTC (permalink / raw)
To: gcc-bugs
% gcc -v
Reading specs from
/tmp_mnt/software/software/gcc/3.4.0/HP-UX-B.11/lib/gcc/hppa2.0w-hp-hpux11.00/3.4.0/specs
Configured with: ../configure --prefix=/software/gcc/3.4.0
--exec-prefix=/software/gcc/3.4.0/HP-UX-B.11 --with-local-prefix=/work
--enable-languages=c,c++ --enable-shared --with-gnu-as --with-as=/work/bin/as
Thread model: single
gcc version 3.4.0
c% cat t.cxx
#include <iostream>
class mystream : public std::iostream {
public:
mystream () {};
};
int main() {
mystream x;
x.rdbuf(std::cout.rdbuf());
x << "foobar" << std::endl;
}
% g++ -o t t.cxx
% ./t
./t
terminate called after throwing an instance of 'std::bad_cast'
what(): St8bad_cast
foobarIOT trap (core dumped)
Analysis: in 3.4.0 a default constructor for basic_istream() was added
(include/.../istream, #562ff)
protected:
explicit
basic_istream(): _M_gcount(streamsize(0)) { }
which leaves the iostream in an ill state. The other CTOR calls
this->init(__sb) which initializes the submembers correctly (ties, exceptions etc).
If I use
mystream () : std::iostream(NULL) {};
in the mystream class definition, the error does not occur.
3.3.2 refuses to compile the above, since no basic_iostream(void) CTOR is found.
IMHO the default CTORs should not leave the object in an ill-defined state.
(call init(NULL)).
The same problem is also present in basic_istream and basic_ostream (mayne
others as well).
Best
R'
--
Summary: bogus default constructor for std::basic_iostream
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ralfixx at gmx dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: hppa2.0w-hp-hpux11.00
GCC host triplet: hppa2.0w-hp-hpux11.00
GCC target triplet: hppa2.0w-hp-hpux11.00
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16251
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/16251] bogus default constructor for std::basic_iostream
2004-06-28 19:48 [Bug libstdc++/16251] New: bogus default constructor for std::basic_iostream ralfixx at gmx dot de
@ 2004-07-05 12:49 ` ralfixx at gmx dot de
2004-07-06 23:09 ` bkoz at gcc dot gnu dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: ralfixx at gmx dot de @ 2004-07-05 12:49 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From ralfixx at gmx dot de 2004-07-05 12:49 -------
(In reply to comment #0)
> Analysis: in 3.4.0 a default constructor for basic_istream() was added
> (include/.../istream, #562ff)
> protected:
> explicit
> basic_istream(): _M_gcount(streamsize(0)) { }
>
> which leaves the iostream in an ill state.
The exact file name in the 3.4.1 distribution is
gcc-3.4.1/libstdc++-v3/include/std/std_istream.h, line 562 ff.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16251
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/16251] bogus default constructor for std::basic_iostream
2004-06-28 19:48 [Bug libstdc++/16251] New: bogus default constructor for std::basic_iostream ralfixx at gmx dot de
2004-07-05 12:49 ` [Bug libstdc++/16251] " ralfixx at gmx dot de
@ 2004-07-06 23:09 ` bkoz at gcc dot gnu dot org
2004-07-07 7:25 ` ralfixx at gmx dot de
` (2 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2004-07-06 23:09 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bkoz at gcc dot gnu dot org 2004-07-06 23:09 -------
these constructors should be protected, not public. I'll change this.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16251
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/16251] bogus default constructor for std::basic_iostream
2004-06-28 19:48 [Bug libstdc++/16251] New: bogus default constructor for std::basic_iostream ralfixx at gmx dot de
2004-07-05 12:49 ` [Bug libstdc++/16251] " ralfixx at gmx dot de
2004-07-06 23:09 ` bkoz at gcc dot gnu dot org
@ 2004-07-07 7:25 ` ralfixx at gmx dot de
2005-06-28 3:24 ` danglin at gcc dot gnu dot org
2005-07-09 16:40 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 10+ messages in thread
From: ralfixx at gmx dot de @ 2004-07-07 7:25 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From ralfixx at gmx dot de 2004-07-07 07:25 -------
(In reply to comment #2)
> these constructors should be protected, not public. I'll change this.
They are already protected (at least the one istream). In the meantime I read
some more about this topic, and it seems that the standard `allows' these
constructors, with the assumption that the derived class calls Init() later.
So maybe just add a comment to those CTORs that user code needs to call Init()
before doing anything with the stream?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16251
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/16251] bogus default constructor for std::basic_iostream
2004-06-28 19:48 [Bug libstdc++/16251] New: bogus default constructor for std::basic_iostream ralfixx at gmx dot de
` (2 preceding siblings ...)
2004-07-07 7:25 ` ralfixx at gmx dot de
@ 2005-06-28 3:24 ` danglin at gcc dot gnu dot org
2005-07-09 16:40 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 10+ messages in thread
From: danglin at gcc dot gnu dot org @ 2005-06-28 3:24 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |danglin at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16251
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/16251] bogus default constructor for std::basic_iostream
2004-06-28 19:48 [Bug libstdc++/16251] New: bogus default constructor for std::basic_iostream ralfixx at gmx dot de
` (3 preceding siblings ...)
2005-06-28 3:24 ` danglin at gcc dot gnu dot org
@ 2005-07-09 16:40 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-09 16:40 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
GCC build triplet|hppa2.0w-hp-hpux11.00 |
GCC host triplet|hppa2.0w-hp-hpux11.00 |
GCC target triplet|hppa2.0w-hp-hpux11.00 |
Keywords| |documentation
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16251
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <bug-16251-658@http.gcc.gnu.org/bugzilla/>]
end of thread, other threads:[~2008-02-10 15:52 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-28 19:48 [Bug libstdc++/16251] New: bogus default constructor for std::basic_iostream ralfixx at gmx dot de
2004-07-05 12:49 ` [Bug libstdc++/16251] " ralfixx at gmx dot de
2004-07-06 23:09 ` bkoz at gcc dot gnu dot org
2004-07-07 7:25 ` ralfixx at gmx dot de
2005-06-28 3:24 ` danglin at gcc dot gnu dot org
2005-07-09 16:40 ` pinskia at gcc dot gnu dot org
[not found] <bug-16251-658@http.gcc.gnu.org/bugzilla/>
2008-02-10 13:02 ` manu at gcc dot gnu dot org
2008-02-10 14:36 ` pcarlini at suse dot de
2008-02-10 15:49 ` paolo at gcc dot gnu dot org
2008-02-10 15:52 ` pcarlini at suse dot de
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).