Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/Make Logic    [ Add a report in this area ]  
Report #:  70031   Status: Open
IDE "Compile" fails to detect dependencies correctly and runs stale code
Project:  Delphi Build #:  12.0.3210.17555
Version:    12.1 Submitted By:   John Bladen
Report Type:  Basic functionality failure Date Reported:  12/19/2008 6:53:37 AM
Severity:    Infrequently encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All versions Internal Tracking #:   267432
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 1
Description
If a procedure/function is added to unit 2 that is used by unit 1, the compiler does not detect the need to recompile unit 1 if unit 1 is already using a procedure/function of the same name from unit 3.

This problem arose when creating a workaround for the Delphi 2009 "Val" bug. Having added a replacement Val procedure to a unit that was used by all other units, the compiler did not compile any of the other units and so they continued to use the default System.Val procedure until Alt+P-B (Build) was used.

Where compile errors occur as a result of adding the newly added procedure/function, the entire application must be rebuilt to locate each error (e.g. dozens of times).
Steps to Reproduce:
[Code pasted as unable to attach files]

To demonstrate:

1) Create a command line project with these three units. Build using Alt+P-B.
2) Uncomment the define in Unit 2.
3) Compile using Ctrl+F9. This appears to succeed, but the resulting EXE is wrong.
4) Build using Alt+P-B. This now fails to compile - which is correct.

---

unit Unit1;

interface

uses
  Unit3, Unit2; // Note the order.

procedure Test;

implementation

procedure Test;
var
  Value:Integer;
begin
  GetValueByParameter(Value)
end;

end.

---

unit Unit2;

// To show the bug, build the application using Alt+P-B, then uncomment the $DEFINE, then press Ctrl+F9.
// The compiler will build the project successfully.
// Now build the project using Alt+P-B. The compile will fail.

// {$DEFINE DemonstrateBuildBug}

interface

{$IFDEF DemonstrateBuildBug}
procedure GetValueByParameter(out Value:Double);
{$ENDIF}

implementation

{$IFDEF DemonstrateBuildBug}
procedure GetValueByParameter(out Value:Double);
begin
  Value:=1.234;
end;
{$ENDIF}

end.

---

unit Unit3;

interface

procedure GetValueByParameter(out Value:Integer);

implementation

procedure GetValueByParameter(out Value:Integer);
begin
  Value:=15;
end;

end.
Workarounds
None
Attachment
None
Comments

None

Server Response from: ETNACODE01