Debug vs Release
I'm experiencing an odd issue with an application I have developed. It parses data from a file and later writes the required elements in a header for a different file. In Debug mode, it compiles perfectly but when I try to compile it in Release mode it writes the data incorrectly. Is there something different between the two that would alter such basic functionality?
Here's an example of a proper vs. improper conversion.
Note: Both outputs are all on one line but I didn't want to stretch the forum frame so I manually added the redundant breakline - also for clarity.
Debug prints out the following (similar to what is read in from a separate file):
Release is giving me:
11 "Input: WOW=True" CAS ADVISE\0
12 "Input: Gear=True" CAS ADVISE\0
13 "Input: Anti-Ice=True" EVENT MESSAGE\0
14 "" IGNORE NONE\0
The code writing this is an iteration through a type struct vector:
unsigned char c = 0x0a;
for (j=0; j<19; j++)
fprintf(out, "%d %s %s %s%c", Bits[j].Bit,
The problem is almost certainly in the place where you're filling the fields, not where you're reading them.
It seems as though it's not filling them at all. Does the call to the function that should be filling them perhaps look anything like this?
I.e. is it within an assert or anything else that gets removed in release builds?
assert(fillFields(...) != -1);
I see what you're getting at, but the code is straight up as above. There is no call to a function and no assertions. The data is read in from a file to the global struct, then later writes the struct to another file as above. I looked through the code for a catch, but I can't find anything.
> Is there something different between the two that would alter such basic functionality?
If the code is bug-free, no.
But what you may find is that memory is arranged differently between debug and release, so a buffer overrun in one may not actually cause any visible problem, but will cause the other to fail horribly.
I scrutinized the code and found a foolish reference to an array location [-1] that was preventing the data-assignment code loop from running. Fixed it and things appear to be spot on regardless of Release or Debug build. Thanks for the help; I probably would have spent hours drilling myself before I'd realize that the assignment function wasn't executing properly. Even though now that I look at it, it was terribly obvious.