Disable Buggy Compiler Warnings Undefined Function Return for Delphi 2007


Before Delphi 2007, sometimes you will have a warning showing up for lengthy functions, even if you have defined return value at the begining of the function, for example:

function test(a: integer): integer;
var
  u, v, w, x, y, z: integer;
  .. .. 
  .. ..
begin
  Result := -1;
  ..
  // lots of code here
  .. 
  .. ..
end;

You will have a warning of ‘The return value of the function test might be undefined’ no matter where you put the return value. This has been reported as a bug and resolved in Delphi 2009. In order to disable this annoying warning. You can enable the compiler directive to make this go away.

{$WARN NO_RETVAL OFF}
function test(a: integer): integer;
var
  u, v, w, x, y, z: integer;
  .. .. 
  .. ..
begin
  Result := -1;
  ..
  // lots of code here
  .. 
  .. ..
end;
{$WARN NO_RETVAL ON}

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
187 words
Last Post: Rectangle Intersection Testing Algorithm
Next Post: Codeforces: A. Is your horseshoe on the other hoof?

The Permanent URL is: Disable Buggy Compiler Warnings Undefined Function Return for Delphi 2007

Leave a Reply