Various command-line behavior in "Run without Debugging"

I scratched my head: I have an application that works fine in Debug + Release, if it started with Visual Studio 2010, both in Debug and in "Run without Debugging". If I run the same application from the command line with the same settings, I see a different behavior. In particular, code that works differently:

const List& vl = nDesc.Get<List> ("slots");

int index = 0;
for (auto it = vl.begin (), end = vl.end (); it != end; ++it)
{
    desc.units [index++] = Parse (Tree (*it));
    // If I access it again here, e.g.
    // Log::Info (std::distance (vl.begin (), it))
    // this works always
}

I would suggest that the state of the race, but the code is completely single-threaded. It is interesting to note that adding some random code does not make it work (i.e. just writing a line is not enough). Oh, and this loop only starts once, ever.

The data in desc is the same, uploading it to a file after the loop indicates that the same data was written. Moving the loop up and down around this piece of code does not help; also does not change auto to List :: const_iterator help.

Any ideas you can start debugging with?

[Update] Turning off optimizations of this function does not fix it for Release, but I can attach a debugger and see that everything works there as expected. But I do not get the correct program behavior. Stills works with Run without Debugging and Run with Debug.

+3
source share
2 answers

I suspect the problem is with the uninitialized heap memory block.

, Windows.

Windows Debug , (0xBAADF00D IIRC), , . ( "" ), , , , , ( , , ).

, , .

, , , , .

(, Windows CRT Debug Heap, Debug , IIRC - 0xCD)

+4

, desc.units , , .

0

All Articles