Step one
Start Delphi XE.
Step Two
Create simple project.
program F2048;
uses
Classes,
StreamEnh;
type
TTest = class(TStream)
end;
begin
end.
Step Three
Create unit StreamEnh.
unit StreamEnh;
interface
uses
SysUtils,
Classes;
type
TGpStreamEnhancer = class helper for TStream
public
procedure BE_WriteDWord(const dw: cardinal);
procedure BE_WriteHuge(const h: Int64);
end;
implementation
procedure TGpStreamEnhancer.BE_WriteDWord(const dw: cardinal);
begin
end;
procedure TGpStreamEnhancer.BE_WriteHuge(const h: Int64);
begin
BE_WriteDWord(Int64Rec(h).Hi);
BE_WriteDWord(Int64Rec(h).Lo);
end;
end.
Step Four
Rebuild.
Expected: Program should compile.
Reality: [DCC Fatal Error] F2048.dpr(1): F2084 Internal Error: C10343
Funny things happen if you don’t restart the Delphi. Try recompiling: [DCC Fatal Error] F2048.dpr(9): F2084 Internal Error: O826
Workaround
Change BE_WriteHuge to use a temporary variable:
procedure TGpStreamEnhancer.BE_WriteHuge(const h: Int64);
var
a: int64;
begin
a := h;
BE_WriteDWord(Int64Rec(a).Hi);
BE_WriteDWord(Int64Rec(a).Lo);
end;
Be aware though that you have to restart Delphi if you want the fixed code to compile. Otherwise you’ll be getting Internal error O826.
QC
Reported as QC #91327. Vote for it!
After an internal compiler error, you MUST restart the Delphi IDE, because it causes the IDE compiler subsystem to end in an unstable state.
ReplyDeleteNot true.
ReplyDeleteAfter an internal compiler error, you MUST install Delphi 7 again... and you are happy again ;-)
and what if you just remove the const from the parameter in that routine?
ReplyDeleteDelphi7, this is a joke?
ReplyDelete@vv75: Doesn't help.
ReplyDeleteDelphi 7 had its share of internal compiler errors that required restarting the IDE for stability again.
ReplyDeleteit would be nice if I could actually vote... "exception, vote limit exceeded" -- WTF?!!
ReplyDeleteEmbarcadero is pushing the envelope very hard...
Just a thought, but what if you make the temporary variable (a) an absolute of the parameter?
ReplyDeleteprocedure TGpStreamEnhancer.BE_WriteHuge(const h: Int64);
var
a: int64 absolute h;
begin
BE_WriteDWord(Int64Rec(a).Hi);
BE_WriteDWord(Int64Rec(a).Lo);
end;
sorry, typed that wrong :-
ReplyDeleteprocedure TGpStreamEnhancer.BE_WriteHuge(const h: Int64);
var
a:int64rec absolute h;
begin
BE_WriteDWord(a.Hi);
BE_WriteDWord(a.Lo);
end;
Of course, you are at the mercy of the format of int64 and int64rec always being compatible.
@Anonymous: That works too.
ReplyDeleteHow irresponsible.... hadn't you heard? Absolute is "holding the language back".
ReplyDelete;)
Pfft. It's stuff like this which makes delphi great. Better than that c# rubbish by a mile :-P
ReplyDelete