On 02/12/2012 21:05, Jonas Maebe wrote:
As always when asking about help with something the compiler does, post a 
complete and compilable program that demonstrates your question. The following 
code does not produce any warning (it will produce hints):


Sorry about that. I had to extract it from same bigger code.

If compiled, with PtrUint (as is below)

Free Pascal Compiler version 2.6.0 [2012/01/04] for i386
Compiling C:\Users\martin\AppData\Local\Temp\project1.lpr
project1.lpr(11,28) Warning: Variable "p" does not seem to be initialized
project1.lpr(11,11) Warning: Conversion between ordinals and pointers is not portable
project1.lpr(9,5) Note: Local variable "darr" is assigned but never used
Linking C:\Users\martin\AppData\Local\Temp\project1.exe


If replace the type
type IPointer = PtrInt;

Free Pascal Compiler version 2.6.0 [2012/01/04] for i386
Compiling C:\Users\martin\AppData\Local\Temp\project1.lpr
project1.lpr(11,28) Warning: Variable "p" does not seem to be initialized
project1.lpr(11,11) Hint: Conversion between ordinals and pointers is not portable
project1.lpr(9,5) Note: Local variable "darr" is assigned but never used
Linking C:\Users\martin\AppData\Local\Temp\project1.exe

So actually the message is just downgraded from Warning to Hint.

and the full command line as issued by Lazarus:
fpc.exe -MObjFPC -Scghi -O1 -gw2 -godwarfsets -gl -gh -vewnhi -Filib\i386-win32 -FUlib\i386-win32\ -l C:\Users\martin\AppData\Local\Temp\project1.lpr"


If I remove the " - PointerSize2" it is always a hint. But the location (11,11) doe not point to thin, it points to the uppercase "P" of this most outer "Pointer()"typecast


program Project1;
{$mode objfpc}{$H+}
uses Classes;
type IPointer = PtrUInt;
const
  PointerSize = IPointer({$IFDEF CPU64}8{$ELSE}4{$ENDIF});
  PointerSize2 = IPointer(2*PointerSize);
var
  p,darr: Pointer;
begin
  darr := Pointer(IPointer(p^) - PointerSize2);
end.

_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to