Strange crashes when accessing the memory

I got this program that worked well 2 weeks ago, I didn't change any parts on where it now crashes.

For example, take this snippet : (assuming is is a valid istream and contains <tag>)

std::string Str;
char c;
for ( ; is >> c; )
    std::cout << c << std::flush;
    Str += c;

Output : < then crash.

I'm using Windows and mingGW, the crash is a window saying that my program has encoutner an error, Windows is trying to fix it...

But this is not all, it crashes the same with Str = c; or when initilizing : std::string Str ("op");

30 minutes after I have found this error, I got another one (previous to the initial one) on a line :

osstr.write((char *) Word, 16);

Where osstr is a valid ostringstream and Word is a filled unsigned char *


The problem is probably NOT in the code. Because a simple call to the string constructor crashes.

std::string Str ("") works

std::string Str ("str"); crash


Right, sorry for incomplete information, but I just couldn't give you the whole code.

The problem came from a buffer overflow far before the code above that didn't crash.

Need Your Help

Vim: Call an ex command (set) from function?

vim function set ex

Drawing a blank on this, and google was not helpful.

How to have in many-to-one relation dictionary table with distinct rows?

java mysql sql hibernate

I have a problem. I have a relation in Hibernate many-to-one - one city can have a lot of student.