SERVING THE QUANTITATIVE FINANCE COMMUNITY

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

DF's usual dumb errors

January 31st, 2012, 4:51 pm

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?
 
User avatar
DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

DF's usual dumb errors

January 31st, 2012, 4:59 pm

Same if I run it from the VS command line, so env vars should be fine.WTF?
 
User avatar
Polter
Posts: 2526
Joined: April 29th, 2008, 4:55 pm

DF's usual dumb errors

January 31st, 2012, 5:18 pm

What do you get when you print out its representation as in here (trivial adjustments required to use doubles instead of floats)?
 
User avatar
DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

DF's usual dumb errors

January 31st, 2012, 5:22 pm

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?
 
User avatar
Polter
Posts: 2526
Joined: April 29th, 2008, 4:55 pm

DF's usual dumb errors

January 31st, 2012, 5:29 pm

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?
 
User avatar
DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

DF's usual dumb errors

January 31st, 2012, 5:41 pm

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.
 
User avatar
zeta
Posts: 1969
Joined: September 27th, 2005, 3:25 pm
Location: Houston, TX
Contact:

DF's usual dumb errors

January 31st, 2012, 11:17 pm

uninitialised variables are a common cause for this difference in behaviour, try valgrind or purify
 
User avatar
spv205
Posts: 478
Joined: July 14th, 2002, 3:00 am

DF's usual dumb errors

February 2nd, 2012, 6:36 pm

did you ever discover the problem?
 
User avatar
DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

DF's usual dumb errors

February 3rd, 2012, 8:19 am

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.
 
User avatar
DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

DF's usual dumb errors

February 6th, 2012, 10:36 am

BTW, I ran Dr. Memory on my code (with /ZI) and got only 1 uninitialized read. Fixed that, but the issue still remains.
 
User avatar
DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

DF's usual dumb errors

February 6th, 2012, 11:17 am

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).
 
User avatar
DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

DF's usual dumb errors

June 25th, 2012, 7:56 pm

Why can't I do this?
 
User avatar
Polter
Posts: 2526
Joined: April 29th, 2008, 4:55 pm

DF's usual dumb errors

June 25th, 2012, 8:07 pm

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
 
User avatar
DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

DF's usual dumb errors

June 25th, 2012, 8:55 pm

It doesn't seem a partial specialization though. I'm looking into overloading. Thanks.
 
User avatar
DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

DF's usual dumb errors

June 25th, 2012, 9:24 pm

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

PW by JB

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...


Twitter LinkedIn Instagram

JOBS BOARD

JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...


GZIP: On