I'm currently working on a project that depends on me providing a path to a file (eg. C:\Path.pth). Now, I had everything working yesterday by calling my std::string with:
std::string path(`"C:\\Path.pth`");
But now it doesn't work. It throws a bad_alloc. Seems like the '\' character is the problem. I even tried using \x5C as the ascii-value of it instead, but same result.
Now, my question is, is it possible that I have screwed up some #define, some compiler-option or something else "non-code" that could've caused this? I'm using VS 2005.
Any help would be much appreciated
PierreBdR
.. That sounds very likely. Or at least, it have to :P
Since no one have mentioned some kind of /SetStringCharSize:2bit-compiler option, I think it's safe to assume that my code has to mess something up, somewhere, and that it's not just a silly compiler-option (or similar) that's wrong..
As your error suggest, the problem is due to memory allocation (i.e. the bad_alloc exception).
So either you have no more memory (unlikely) or you have a buffer overrun somewhere before (quite likely in my opinion) or some other memory issues like double free.
In short, you do something that messes up the memory management layout (i.e. all these information in between allocated blocks). Check on what happens before this call.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With