visual studio 2005 - What could be causing this memory access error (C++)? Might be undefined behavior? -


i have relatively large class i'm working , it's worked fine far (note: didn't write class, i'm adding functionality). however, after declaring 1 more string in header file, crashes (i memory access error). if erase string , rebuild, works fine.

i'm not doing string....just act of declaring causing weird memory error.

i can't explain in more detail this, since waste try explain every function. kind of things should here find problem? might cause weird behavior?

the error is:
unhandled exception @ 0x65fd17fd (msvcp80d.dll) in myfile.exe: 0xc0000005: access violation writing location 0xcdcdcdcd.

basically changed in .h file was:

stringtype string1; 

turned into:

stringtype string1; stringtype string2; 

stringtype extension of basic_string

you've allocated memory on heap , failed initialize it.

0xcd fill pattern used debug heap: before dynamically allocated memory given program, filled pattern find uninitialized variables.

as why changing class definition affects outcome, may doing incorrect pointer arithmetic, accessing beyond end of dynamically allocated object, or 1 of number of other things no longer manifests bug when have larger object. violating one-definition rule if of source built using old definition , of source built new definition.

there many things can cause kind of problem: best bet break in debugger when happens, , trace backwards see error originated (sometimes can lots of fun; had trace uninitialized variable across network connection once).


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -