|
From: TheDevil on 14 Apr 2008 18:56 Hello, See comments or website for details. http://members.home.nl/hbthouppermans/VS2008Analysis/Index.htm // *** Begin of Main.cpp *** #include <stdio.h> #include <windows.h> typedef char int8; typedef short int int16; typedef int int32; typedef long long int64; typedef unsigned char uint8; typedef unsigned short uint16; typedef unsigned int uint32; typedef unsigned long long uint64; /* 15 april 2008 Lesson 7, Condition Evaluation, Full vs Partial Mission: Test if Visual Studio 2008 c/c++ does full condition evaluation or partial condition evaluation by default. Test if Visual Studio 2008 c/c++ has option to choose between the two. Conclusions: Visual Studio 2008 c/c++ does partial condition evaluation by default. Visual Studio 2008 c/c++ does not have an option to choose between the two. Partial condition evaluation is fast and good for performance. Full condition evaluation does not seem possible and could prevent code analysis/debugging to find these kind of bugs. (For example function might do something important but never gets called). No way to know if what it does would have worked. Test1 ok. (partial condition evaluation best for performance, upper condition is tested first, evalation stopped as soon as one of the conditions becomes false.) Test2 failed. Score: 5 out of 10. */ int8 SomeFunction1( int8 SomePara1 ) { printf("SomeFunction1 called \n"); if (SomePara1 < 0) { return 0; } else { return 1; } } int8 SomeFunction2( int8 SomePara1 ) { printf("SomeFunction2 called \n"); if (SomePara1 < 0) { return 0; } else { return 1; } } int8 SomeFunction3( int8 SomePara1 ) { printf("SomeFunction2 called \n"); if (SomePara1 < 0) { return 0; } else { return 1; } } int main() { printf("Program Started \n"); int8 Variable1; int8 Variable2; int8 Variable3; int8 Condition1; int8 Condition5; Condition1 = 1; Variable1 = (int8)(GetTickCount()); Sleep( uint8(Variable1) ); Variable2 = (int8)(GetTickCount()); Sleep( uint8(Variable2) ); Variable3 = (int8)(GetTickCount()); Sleep( uint8(Variable3) ); Condition5 = 10; while ( (Condition1 == 1) && (SomeFunction1( Variable1 ) == 1) && (SomeFunction2( Variable2 ) == 1) && (SomeFunction3( Variable3 ) == 1) && (Condition5 > 0) ) { printf("DoSomeWork \n"); Condition5 = Condition5 - 1; } printf("Program Finished \n"); return 0; } // *** End of Main.cpp *** Bye, The Devil.
From: Ian Collins on 14 Apr 2008 18:57 TheDevil wrote: > Hello, > > See comments or website for details. > > http://members.home.nl/hbthouppermans/VS2008Analysis/Index.htm > > // *** Begin of Main.cpp *** > > #include <stdio.h> > #include <windows.h> > What's that? > typedef char int8; > typedef short int int16; > typedef int int32; > typedef long long int64; > > typedef unsigned char uint8; > typedef unsigned short uint16; > typedef unsigned int uint32; > typedef unsigned long long uint64; > Why not use standard types? > Mission: > > Test if Visual Studio 2008 c/c++ does full condition evaluation or partial > condition evaluation by default. > Test if Visual Studio 2008 c/c++ has option to choose between the two. > Why would we care what Visual Studio does? Your test is basically stupid, the behaviour you are "testing" is mandated by the language standard. -- Ian Collins.
From: Alf P. Steinbach on 14 Apr 2008 19:03 * Ian Collins: > TheDevil wrote: >> Hello, >> >> See comments or website for details. >> >> http://members.home.nl/hbthouppermans/VS2008Analysis/Index.htm >> >> // *** Begin of Main.cpp *** >> >> #include <stdio.h> >> #include <windows.h> >> > What's that? > >> typedef char int8; >> typedef short int int16; >> typedef int int32; >> typedef long long int64; >> >> typedef unsigned char uint8; >> typedef unsigned short uint16; >> typedef unsigned int uint32; >> typedef unsigned long long uint64; >> > Why not use standard types? > > >> Mission: >> >> Test if Visual Studio 2008 c/c++ does full condition evaluation or partial >> condition evaluation by default. >> Test if Visual Studio 2008 c/c++ has option to choose between the two. >> > Why would we care what Visual Studio does? > > Your test is basically stupid, the behaviour you are "testing" is > mandated by the language standard. Perhaps he's enrolled in a course where they're supposed to learn by "testing" the various language and library features, and that the scores are the scores he's getting by handing in these assignments? Just a theory. Cheers, - Alf
From: TheDevil on 14 Apr 2008 19:13 See StarTrek: The Next Generation, First Episode. Captain Picard tests his spaceship. ^ Smart dude.
From: Ian Collins on 14 Apr 2008 19:09
[what are you replying to?] TheDevil wrote: Twaddle -- Ian Collins. |