3

can anyone tell me why I get "Return value ... might be undefined" here:

function TXMLAcceptorBCOLSubmission.createRecordsInBCFEEPAR(AXML: TRipXMLElement): String;
var
  ...
begin
  Result := '';
1
  • 7
    Could you show the complete code? Commented Sep 8, 2010 at 9:33

2 Answers 2

5

I am using Delphi 5 and it looks like the problem is caused by declaring more than 30 variables (I know, I know). It doesn't seem to matter what they are called or what types they are.

Sign up to request clarification or add additional context in comments.

3 Comments

Indeed; this was a bug that has been resolved in Delphi 2009: qc.embarcadero.com/wc/qcmain.aspx?d=51078
That fits with my experience. There seems to be a certain number of variables the compiler will "track" for the assignedness check, and Result is frequently the first to be abandoned. The workaround is simple: Write shorter functions.
Report 51078 says that it was fixed in 12.0.2872.27234, but I'm pretty sure that I saw it in D2010.
2

Following code doesn't generate a warning using Delphi 5 so

  • either it is a bug in an other Delphi version (you should mention the version you use)
  • or either it is something you didn't show us yet.

Code

program ProveAPoint;
{$APPTYPE CONSOLE}
uses SysUtils;

type
  TRipXMLElement = record
  end;
  TXMLAcceptorBCOLSubmission = class
  public
    function createRecordsInBCFEEPAR(AXML: TRipXMLElement): string;
  end;

function TXMLAcceptorBCOLSubmission.createRecordsInBCFEEPAR(AXML: TRipXMLElement): String;
begin
  Result := '';
end;

var
  AXML: TRipXMLElement;
begin
  with TXMLAcceptorBCOLSubmission.Create do
  begin
     createRecordsInBCFEEPAR(AXML);
     Free;
  end;
end.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.