[fpc-devel]Many new warnings

Mattias Gaertner nc-gaertnma at netcologne.de
Fri May 28 17:48:51 CEST 2004


The current cvs fpc 1.9.3 gives many new warnings. The following code
demonstrates 6 types, where I'm not sure why they now need a warning.
Maybe the compiler cracks can tell me, which of them should I report as
bugs:

program IncredibleWarnings;

{$mode objfpc}{$H+}

// range checks on
{$R+}

uses
  Classes, SysUtils; 

procedure DoSomething;
const
  k = $FFFFFF;
var
  ACardinal: LongWord;
  AnInteger: integer;
  AnException: Exception;
begin
  ACardinal:=0; AnInteger:=0;
  
  // Warning: Mixing signed expressions and longwords gives a 64bit result
  inc(ACardinal);
  if (1 shl AnInteger)>=AnInteger then ;
  ACardinal:=ACardinal-sizeof(char);
  if ACardinal=k then ;
  if ACardinal=ord(ssLeft) then ;

  // Note: Local variable "AnException" is assigned but never used
  AnException:=Exception.Create('');
  raise AnException;
end;

begin
  DoSomething;
end.


Mattias


-- 




More information about the fpc-devel mailing list