Click here to Skip to main content
15,889,034 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
Stefan_Lang19-Jan-14 23:29
Stefan_Lang19-Jan-14 23:29 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
Stefan_Lang19-Jan-14 23:44
Stefan_Lang19-Jan-14 23:44 
QuestionRe: Bug in Visual Studio 2005 compiler? Pin
Richard MacCutchan20-Jan-14 0:21
mveRichard MacCutchan20-Jan-14 0:21 
AnswerRe: Bug in Visual Studio 2005 compiler? Pin
Stefan_Lang20-Jan-14 0:24
Stefan_Lang20-Jan-14 0:24 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
a_matseevsky20-Jan-14 0:52
a_matseevsky20-Jan-14 0:52 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
Stefan_Lang20-Jan-14 1:21
Stefan_Lang20-Jan-14 1:21 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
a_matseevsky20-Jan-14 2:06
a_matseevsky20-Jan-14 2:06 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
Stefan_Lang20-Jan-14 3:46
Stefan_Lang20-Jan-14 3:46 
You should be aware that asking us which optimized code would work and which wouldn't, without posting the full code with declarations and optimizer settings is ludicrous.

Therefore I decided to derive it based on you statements elsewhere: Variant B contains code that works by your own statement elsewhere. neither contains the max() funtion you refer to in your original question. So B is the working and A the not working - albeit not the original - version. Q. E. D.

As for what is pointless or not: advice is only pointless if it isn't heeded. You believe that the debugger shows you every information correctly? It doesn't. It can't. It's physically impossible.

I've dealt with optimizers 30 years ago: back then it wasn't to hard to anticipate what it would do, and in C you could often emulate pretty much the same without having to invoke the optimizer at all. meaning well optimized C code ran almost as well in debug mode as it did in release.

I've dealt with optimizers 20 years ago, and it got more tricky. Still, well optimized C-code often turned out to be near optimal.

I've dealt with optimizers 10 years ago, and the experience was very different: for one, the same optimizations in C code sometimes led to slower code, because it prevented the optimizer from performing extremely sophisticated optimizations that you'd never have thought of. Plus the size of the codebase made it impossible to optimize all of your code in that way anyway.

At that point I stopped trying to optimize my C/C++ code by hand.

Nowadays, when I check release code that doesn't do the same as debug code, I often find that half the variables aren't on stack, and some others get overwritten at unexpected moments. At least when I look at them through the debugger. It's the optimizer at work! What I usually do is pinpoint the location where everything goes south, then insert some print statements to ensure everything is as I expect it to be - and in 9 cases out of 10, something will not be as I expect it to be! And the debugger won't be able to show it!

That's why I keep telling you not to trust the debugger - and looking at the assembler code doesn't change that you're using the debugger.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

GeneralRe: Bug in Visual Studio 2005 compiler? Pin
a_matseevsky20-Jan-14 12:30
a_matseevsky20-Jan-14 12:30 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
a_matseevsky20-Jan-14 1:27
a_matseevsky20-Jan-14 1:27 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
Stefan_Lang20-Jan-14 1:59
Stefan_Lang20-Jan-14 1:59 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
a_matseevsky20-Jan-14 2:42
a_matseevsky20-Jan-14 2:42 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
Stefan_Lang20-Jan-14 3:33
Stefan_Lang20-Jan-14 3:33 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
a_matseevsky20-Jan-14 12:46
a_matseevsky20-Jan-14 12:46 
AnswerRe: Bug in Visual Studio 2005 compiler? Pin
jschell17-Jan-14 13:16
jschell17-Jan-14 13:16 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
a_matseevsky17-Jan-14 14:33
a_matseevsky17-Jan-14 14:33 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
Richard MacCutchan17-Jan-14 22:24
mveRichard MacCutchan17-Jan-14 22:24 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
a_matseevsky18-Jan-14 0:46
a_matseevsky18-Jan-14 0:46 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
Richard MacCutchan18-Jan-14 1:13
mveRichard MacCutchan18-Jan-14 1:13 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
a_matseevsky18-Jan-14 10:01
a_matseevsky18-Jan-14 10:01 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
Richard MacCutchan18-Jan-14 22:13
mveRichard MacCutchan18-Jan-14 22:13 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
a_matseevsky19-Jan-14 1:07
a_matseevsky19-Jan-14 1:07 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
Richard MacCutchan19-Jan-14 1:08
mveRichard MacCutchan19-Jan-14 1:08 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
a_matseevsky19-Jan-14 10:54
a_matseevsky19-Jan-14 10:54 
GeneralRe: Bug in Visual Studio 2005 compiler? Pin
pkfox19-Jan-14 20:20
professionalpkfox19-Jan-14 20:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.