This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: BUG with g++ version 2.7.2.3
- To: jhinsley at telinco dot co dot uk
- Subject: Re: BUG with g++ version 2.7.2.3
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Sat, 25 Mar 2000 23:52:39 +0100
- CC: egcs-bugs at egcs dot cygnus dot com
- References: <38DCAF6A.1C2F9B7D@telinco.co.uk>
> The code which produced this error is so simple I might as well send it
> all.
Thanks for your bug report. This is not a bug in g++, but in your
code. Looking at
char oddeven[1];
...
cin>> oddeven;
you might notice that there is no
operator>>(istream&,char[1]). Instead, the operator>>(istream&,char*)
is called. This one reads until the end-of-line character. Since you
only provide space for a single character, it overwrites arbitrary
memory - in your case the pong variable.
You can correct your code by writing
char oddeven;
Regards,
Martin