DelphiFAQ Home Search:

Return value of function XYZ might be undefined

 

comments2 comments. Current rating: 4 stars (1 votes). Leave comments and/ or rate it.

Question:

I seem to be getting a bogus warning about an undefined function result. Can anyone confirm this?

Answer:

Both Delphi 5 and Delphi 6 will report:
Return value of function Undefined2 might be undefined

Delphi 7 will complain about Undefined1 as well.
Return value of function Undefined1 might be undefined
Return value of function Undefined2 might be undefined

This is a bug in Delphi 7.

program Project1;

function Undefined1 : boolean;
var
  b: boolean;
begin { Undefined1 }
  Undefined1 := False;
  b := True;
  if b then
    Undefined1 := True
end; { Undefined1 }


function Undefined2 : boolean;
var
  b: boolean;
begin { Undefined2 }
  b := True;
  if b then
    Undefined2 := True
end; { Undefined2 }


begin

end.
You don't like the formatting? Check out SourceCoder then!
Content-type: text/html

Comments:

2006-08-01, 06:33:25
[hidden] from France  
rating
I got the same problem with strings

function myFunction(...) : String;
begin
Result := EmptyStr;
// some initialization stuff
try
try
// lot of stuff, not dealing with Result
except
on E:Exception do
Result := E.Message;
end;
finally
// finalization stuff, not dealing with Result
end;
end;

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: