

|
 |
| << Topic |
< Post |
Post 1 of 7 Topic 4114 of 4193
|
Post > |
Topic >> |
Lesson 7, Condition Evaluation, Full vs Partial.
by "TheDevil" <TheDevil@[EMAIL PROTECTED]
>
Apr 15, 2008 at 12:56 AM
| 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 im****tant 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.


|
7 Posts in Topic:
|
"TheDevil" < |
2008-04-15 00:56:24 |
|
Ian Collins <ian-news@ |
2008-04-15 10:57:46 |
|
"Alf P. Steinbach&qu |
2008-04-15 01:03:25 |
|
"TheDevil" < |
2008-04-15 01:13:02 |
|
Ian Collins <ian-news@ |
2008-04-15 11:09:56 |
|
"TheDevil" < |
2008-04-15 01:27:26 |
|
"TheDevil" < |
2008-04-15 01:46:22 |
|
Post A Reply:

|
|
|
|