Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Borland Delphi > Strange bug wit...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 3668 of 3852
Post > Topic >>

Strange bug with QueryPerformanceCounter, Int64, Nodes and Aliases ?!?!?

by "Skybuck Flying" <spam@[EMAIL PROTECTED] > Mar 29, 2008 at 01:02 PM

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 := @[EMAIL PROTECTED]
 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.
 




 1 Posts in Topic:
Strange bug with QueryPerformanceCounter, Int64, Nodes and Alias
"Skybuck Flying"  2008-03-29 13:02:54 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 19:27:02 CDT 2008.