Strange bug with QueryPerformanceCounter, Int64, Nodes and Aliases ?!?!?
- From: "Skybuck Flying" <spam@xxxxxxxxxxx>
- Date: Sat, 29 Mar 2008 13:02:54 +0100
Hello,
The following code uses nodes, it uses aliases to prevent having to typecast
stuff.
Then it calls QueryPerformanceCounter( SomeNodeRecord.Int64Field ).
And then for some reason it doesn't work, Int64Field is always zero ?
Take a look at this and tell me what you think:
// *** Begin of Code ***
program Project1;
{$APPTYPE CONSOLE}
{
Test strange compiler bug with nodes and aliases.
Version 0.01 created on 29 march 2008 by Skybuck Flying !!!
Compiler bugs starting to piss me off ! :)
Keep cool ! =D :):):)
At the same time funny though :)
This serious bug though ?!?
}
uses
SysUtils, Windows;
type
Pnode = ^Tnode;
Tnode = packed record
mNext : Pnode;
mPrev : Pnode;
mData : packed record end;
end;
TMyMethod = procedure of object;
PMyNode = ^TmyNode;
TMyNode = packed record
mNext : PmyNode;
mPrev : PmyNode;
mMethod : TmyMethod;
mDone : boolean;
mTicks : int64;
end;
var
Test : TMyNode;
function Return( var Node : Pnode ) : boolean;
begin
Node := @Test;
result := true;
end;
procedure TestInt64( var I : int64 );
begin
I := 666;
end;
procedure Main;
var
MyNodeTyped : PmyNode;
MyNodeUntyped : Pnode absolute MyNodeTyped;
vTest : int64;
begin
if Return( MyNodeUntyped ) then
begin
with MyNodeTyped^ do
begin
mDone := false;
mMethod := nil;
QueryPerformanceCounter( mTicks ); // DOES NOT WORK. STRANGE !!!
writeln( mTicks ); // ALWAYS PRINTS ZERO.
TestInt64( mTicks ); // DOES WORK. Bug seems to be related to
QueryPerformanceCounter in combination with alias ?
writeln( mTicks );
QueryPerformanceCounter( vTest ); // does work..
writeln( vTest );
end;
end;
end;
begin
try
Main;
except
on E:Exception do
Writeln(E.Classname, ': ', E.Message);
end;
readln;
end.
// *** End of Code ***
Bye,
Skybuck.
.
- Prev by Date: Re: CodeGear are HERO'S !!! =D
- Next by Date: Re: CodeGear are HERO'S !!! =D
- Previous by thread: Re: *** Fitna, the most beautifull film of the last decade ***
- Next by thread: E2161 Duplicate string
- Index(es):