<p>I have a function that gives me the following warning:</p>

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

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

<pre><code>Result := '';
</code></pre>

<p>and there is no local variable or parameter called <code>Result</code> either.</p>

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

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

<p>Anyone know off the top of their head what i can do?</p>

[{'answer_id': 61424, 'author': 'Espo', 'author_id': 2257, 'author_profile': 'https://Stackoverflow.com/users/2257', 'pm_score': 1, 'selected': False, 'text': '<p>There seems to be some sort of bug in Delphi. Read this post, the last comment links to other bug-reports that may be the one that you have got:</p>\n\n<p><a href="http://qc.codegear.com/wc/qcmain.aspx?d=8144" rel="nofollow noreferrer">http://qc.codegear.com/wc/qcmain.aspx?d=8144</a></p>\n'}, {'answer_id': 61426, 'author': 'Lars Truijens', 'author_id': 1242, 'author_profile': 'https://Stackoverflow.com/users/1242', 'pm_score': 4, 'selected': True, 'text': '<p>Are you sure you have done everything to solve the warning? Maybe you could post the code for us to look at?</p>\n\n<p>You can turn off the warning locally this way:</p>\n\n<pre><code>{$WARN NO_RETVAL OFF}\nfunction func(...): string;\nbegin\n  ...\nend;\n{$WARN NO_RETVAL ON}\n</code></pre>\n'}, {'answer_id': 61814, 'author': 'Jim McKeeth', 'author_id': 255, 'author_profile': 'https://Stackoverflow.com/users/255', 'pm_score': 1, 'selected': False, 'text': '<p>The {$WARN NO_RETVAL OFF} is what you are looking for, but generally I like to find out why stuff like this happens.  You might consider formatting it differently and seeing if that helps.  </p>\n\n<p>Do you have any flow altering commands like Exit in there?  Do you directly raise exceptions, etc?  Does your case statement have an else at the end that sets a value on Result?  </p>\n\n<p>Might try tweaking those elements and see if that eliminates the warning too. </p>\n'}, {'answer_id': 66982, 'author': 'Nick Hodges', 'author_id': 2044, 'author_profile': 'https://Stackoverflow.com/users/2044', 'pm_score': 1, 'selected': False, 'text': "<p>In order to get a good answer for this, you'll have to post the code.  In general, the Delphi compiler will give this warning if there is a possible code path that could result in the Result not being defined.  Sometimes that code path is less than obvious.</p>\n"}, {'answer_id': 69778, 'author': 'Lars Fosdal', 'author_id': 10002, 'author_profile': 'https://Stackoverflow.com/users/10002', 'pm_score': 2, 'selected': False, 'text': '<p>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?</p>\n'}, {'answer_id': 2906623, 'author': 'Abelevich', 'author_id': 11391, 'author_profile': 'https://Stackoverflow.com/users/11391', 'pm_score': 1, 'selected': False, 'text': "<p>There is such a bug in Delphi compiler since, at least, Delphi4: if sum of numbers of function's parameters (including Self and Result) and local variables exceeds 31, it causes problems. For example, it can write W1035 warnings (result might be undefined). It can miss not used variables. Just try this project:</p>\n\n<pre><code>program TestCompilerProblems;\n\nprocedure Proc;\nvar\n  a01, a02, a03, a04, a05, a06, a07, a08, a09, a10,\n  a11, a12, a13, a14, a15, a16, a17, a18, a19, a20,\n  a21, a22, a23, a24, a25, a26, a27, a28, a29, a30,\n  a31, a32, a33, a34, a35, a36, a37, a38, a39, a40: Integer;\nbegin\nend;\n\nbegin\n  Proc;\nend.\n</code></pre>\n\n<p>It would cause 31 hint, not 40.</p>\n"}]
['https://Stackoverflow.com/questions/61418', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/267/']