SERVING THE QUANTITATIVE FINANCE COMMUNITY

• 1
• 2

DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

### DF's usual dumb errors

OK, so after the Debug vs. Release thread, let me introduce a new fancy&bizarre behaviour of my program.In debug mode, looking at a specific variable (a double). When running the VS debugger, I can see it has the value I expect (neq 0).When running the same exe _from command line_, the same variable is cout'd as 0. It turns out that in this case the variable is really 0 (if I sum it to "something else", and cout the result I get "something else").So different results running from VS debugger or command line. The main takes no arguments.Since it is debug mode in both cases (and I'm running the correct exe from command line), I've no clue. Environment variables?

DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

### DF's usual dumb errors

Same if I run it from the VS command line, so env vars should be fine.WTF?

Polter
Posts: 2526
Joined: April 29th, 2008, 4:55 pm

### DF's usual dumb errors

What do you get when you print out its representation as in here (trivial adjustments required to use doubles instead of floats)?

DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

### DF's usual dumb errors

QuoteOriginally posted by: PolterWhat do you get when you print out its representation as in here (trivial adjustments required to use doubles instead of floats)?Will see, thanks.However, it appears the program doesn't step into some methods when launched from command line. If I follow the program flow using the debugger, it works as expected.So question is are you aware of any difference between: clicking on "play" in VS and running the debug version of the exe from command line?

Polter
Posts: 2526
Joined: April 29th, 2008, 4:55 pm

### DF's usual dumb errors

Thankfully, I've never experienced this behavior.Apparently it's not unheard of, though: http://stackoverflow.com/questions/5352 ... cidentally, do you also observe different behavior when running by F5 compared to when running by Ctrl+F5?

DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

### DF's usual dumb errors

Nope, works fine (same behaviour) with F5 and Ctrl+F5.It's not entirely my library though, so I think I'm going to have a nice evening fixing this... EDIT: BTW, thanks for the link Master, it helps a lot. My code is pure C++03.
Last edited by DevonFangs on January 30th, 2012, 11:00 pm, edited 1 time in total.

zeta
Posts: 1969
Joined: September 27th, 2005, 3:25 pm
Location: Houston, TX
Contact:

### DF's usual dumb errors

uninitialised variables are a common cause for this difference in behaviour, try valgrind or purify

spv205
Posts: 478
Joined: July 14th, 2002, 3:00 am

### DF's usual dumb errors

did you ever discover the problem?

DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

### DF's usual dumb errors

QuoteOriginally posted by: spv205did you ever discover the problem?Nope, I'm a bit busy these days. For now I'm crunching some numbers with Ctrl+F5. I'll let you know.

DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

### DF's usual dumb errors

BTW, I ran Dr. Memory on my code (with /ZI) and got only 1 uninitialized read. Fixed that, but the issue still remains.

DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

### DF's usual dumb errors

OK fixed.Somewhere in the lib a config file is read, but it's not checked whether the file is properly opened (shame on them) so I didn't notice before. Problem is that apparently when I hit Ctrl+F5 and when I run the exe the relative paths are different. Evidently not the same exe is launched by VS (thing that I suspected).

DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

### DF's usual dumb errors

Why can't I do this?

Polter
Posts: 2526
Joined: April 29th, 2008, 4:55 pm

### DF's usual dumb errors

Hey, I told you that you can find answers to these questions using Clang! ;-)See: http://llvm.org/demo/ // "error: function template partial specialization is not allowed"Why not overload?See: http://www.gotw.ca/publications/mill17.htm

DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

### DF's usual dumb errors

It doesn't seem a partial specialization though. I'm looking into overloading. Thanks.

DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

### DF's usual dumb errors

Yes, overload did the trick. It was actually quite silly of me (as usual).Thanks prof Polter