Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable a warning in Delphi about "return value ... might be undefined"?

I have a function that gives me the following warning:

[DCC Warning] filename.pas(6939): W1035 Return value of function 'function' might be undefined

The function, however, is clean, small, and does have a known, expected, return value. The first statement in the function is:

Result := '';

and there is no local variable or parameter called Result either.

Is there any kind of pragma-like directive I can surround this method with to remove this warning? This is Delphi 2007.

Unfortunately, the help system on this Delphi installation is not working, therefore i can't pop up the help for that warning right now.

Anyone know off the top of their head what i can do?

like image 368
Lasse V. Karlsen Avatar asked Sep 14 '08 15:09

Lasse V. Karlsen


2 Answers

Are you sure you have done everything to solve the warning? Maybe you could post the code for us to look at?

You can turn off the warning locally this way:

{$WARN NO_RETVAL OFF}
function func(...): string;
begin
  ...
end;
{$WARN NO_RETVAL ON}
like image 199
Lars Truijens Avatar answered Sep 23 '22 13:09

Lars Truijens


I am not sure that I want to see the code for this unit... after all, the error occurs at line 6939 ... Maybe some internal compiler table have been exceeded?

like image 24
Lars Fosdal Avatar answered Sep 22 '22 13:09

Lars Fosdal