I'm having difficulties when changing from 32 to 64. every single line of the code gives me an error. for example the following function works well in 32 but for the same function in 64 the code was abrobted;
You should also explain what compiler/version you're using, and show the end result command-line being generated. It looks like you're looking into the internals of one of the Visual Studio container headers? You also didn't say what the error message was. It's probably more of an environmental/configuration issue than a code issue.
Edit: I was assuming this was a compiler error. But now I see you said it was aborted, so I'd go with what helios said.
Unless one of those values that are being passed to std::vector::resize() is uninitialized, I would guess that the program corrupted the heap at some earlier point, in which case the fact that it crashed here doesn't tell you anything about where the bug actually is. You'll need to comb through the entire program looking for where you might be reading or writing things out of bounds, or use a memory debugger like Valgrind.
PS: It's probably just a coincidence that the bug is triggered when you compile for x86-64. It's quite likely that you would have run into the same issue if you, for example, tried building the program with a different compiler, or slightly different compiler flags.
@Ganado
my problem with 64 started with two errors, "The code execution cannot proceed because dll was not found" and "the application was unable to start correctly 0xc00007b". then I tried many things to fix this. now I am afraid maybe I changed some configurations which cause these kind of problems. Almost in any simple code I have problem when moving from 32 to 64.
That isn't much help then. Show us some code that does NOT run on a 64-bit platform.
That complete code compiled and ran without errors with both g++ and cl.exe compilers on my 64-bit operating system, compiled for default (64-bit).
Your posts aren't clear.
- IF that code RUNS on your 64-bit machine then it is likely that there is an out-of-bounds or undefined-variable error in your larger code which you happened to get away with in 32-bit.
- If that complete small code did NOT run on your 64-bit machine then you have an IDE/compiler configuration error.
Please clear up whether that last, complete code did or did not run on your 64-bit machine.
@lastchance
How it comes that this error does not appear in the 32 but shows itself in 64? It's because of the difference in variable size in the two platforms?
@Cplusc,
Please answer my question and stop making the thread ever more incoherent!
An error because of attempted access outside array bounds may not actually cause the code to crash in one case, say 32-bit - but it will still be an error. That error may, however, cause the code to crash in 64-bit, simply because of a different layout of memory.
You need to post some standalone, compileable and runnable code that you claim runs on 32-bit but not 64-bit. We can't reproduce your problem without it.
Your answers are so confusing that we can't even tell if a simple "Hello, world" program runs on your 64-bit machine.
in privoius answer there was a typo. THEY ARE NOT MIXED. BOTH THE EXE AND ANY USED .DLL ARE THE SAME - ALL 32 BIT OR ALL 64 BIT.
A simple "hello world" will run on both 32 and 64.
ok,Let me provide one stand alone compateable code, I'll post in this tread.
for some small codes, the code run on 64-bit machine but in some other it gives me an error "heap corruption detected after normal block c++(#151) at 0*001E3518.CRT detected that the application wrote to memory after end of heap buffer"
Could be because for 32 bit sizeof(int) is usually the same as sizeof(int*) which isn't true for 64 bit. There could be an allocation issue somewhere not allocating enough memory.
Probably going out of bounds of a heap-allocated object.
I'm inclined to agree.
Looking at the variable-naming convention in the code snippet given, the addition of a single '_' to the end of an index would produce compileable code but would attempt access beyond the array.
@Cplusc, please turn the debugger on. If you are doing it from the command line then just cl /EHsc /Zi temp.cpp
then gdb temp.exe (and run)
Adding the line GradP_[1][1][nNodes_global_] = 1.0;
to your working code would soon crash it and produce a comparable error report.
@seeplus
if this is the case (which I think it it). Waht should I do to fix this, changing the variable type can help? I have lots of size_t variables in my code which On a 32-bit system size_t will take 32 bits, on a 64-bit one 64 bits. even this makes problem for my MPI. becuase in this case there will be a problem when receiving data and not having enough space for that.
@Cplusc, the size of the variable is irrelevant. 64-bit machines are perfectly capable of storing 4-byte integers. The red herring was pointers. You aren't kicking pointers around in MPI.
Work on producing a simple but complete piece of code for us.