Jump to content
Science Forums

Recommended Posts

Posted

Wow! After hours of painful troubleshooting today, I solved the above mystery, it was the age-old copy-paste effect!A colleague of mine always says: "If it were up to me, I'd deduct a few cents of pay for each copy-paste a programmer does in writing code!" and he does have a point. :hammer:

 

What I discovered was that the cause of hard crashes in a new job I've done, which uses that job and when I did some optimizing, was the same cause of the wrong calculations back then. The hard crashed prevented all the debug logging and stuff, it was the "just compile and recompile" method... :xx: It turned out that, with a hurried copy and modify to save typing, I had unwittingly aliased RES and DRES :doh: but the use of the variable c in the final version was making DRES redundant except for clarity, so that deallocation of DRES was really deallocation of RES. The new job repeats calls to the old one and, when I tried refactoring it to avoid repetiton of initial and final stuff, including allocation and deallocation of RES, the result was disaster! :D

Posted

I've just become far too accustomed to the fancy IDEs I guess. All along I could have used the memory debugging by just addng a #define DEBUG_MEM and, also, last week I had forgotten I could run the thing from command line and have a printf here and there, instead of logging.

  • 1 month later...
Posted

What will be the last value output, before the following program halts?

#include "stdio.h"

void main(){
for(double db=0; db<0.8; db+=0.1)
	printf("n%f", db);
}

:hihi:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...