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]

Re: BUG with g++ version 2.7.2.3


> 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

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