I'm running Rad Studio XE7, I have run into a problem. Wonder if you all can help.

I'm running Rad Studio XE7, I have run into a problem. Wonder if you all can help.

I have isolated my problem to this example code below, I think it may be a bug. I'm wondering if anybody else can test this in either their copy of XE7 and higher and give me some feedback. I'm using similar constructs all over my code, which was working and for some reason now fails with an access violation. Any thoughts would be great.

Code:

unit Unit1;

interface

uses
Winapi.Windows,
Winapi.Messages,
System.SysUtils,
System.Variants,
System.Classes,

Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs;

type

TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
public
end;

var
Form1: TForm1;

const
ABYTE_DEF = 0;

var
BytesConst: TBytes = [1, 2, 3, 4];

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
aBytes: TBytes;
begin
aBytes := BytesConst + [ABYTE_DEF];
end;

end.

Nothing on the form just hook up the OnCreate to the FormCreate method. Hit run in debugger and an Access Violation occurs. I have traced using madExcept and the call stack shows the error in @DynArrayCopyRange.

Any thoughts? Could you tell me if it work ok in higher versions of Delphi.
Many Thanks.

Comments

  1. Thanks, now just to see if anybody with XE7 has the same problem as me, so I can stop pulling my hair out :-)

    ReplyDelete
  2. ... and see no problems in XE7 update 1.
    21.0.17707.5020

    ReplyDelete
  3. Thanks, Looking at my version it is XE7 21.0.17017.3725..perhaps not update 1 ? I just upgraded my madExcept, and it ran perfectly fine the first time and then the second time I ran it I got an AV again. Strange.

    ReplyDelete
  4. Just had a look at the fixes list of update 1 and don't see anything related to my problem :-(

    ReplyDelete
  5. I think it's time to convince the boss for an upgrade :-)

    ReplyDelete
  6. Why not install the last update for XE7?

    ReplyDelete
  7. I will do so shortly and see if it fixes it.

    ReplyDelete
  8. Embarcadero® Delphi XE7 Version 21.0.17707.5020
    I get the same Error.
    If i step trough the debugger i see in
    procedure _DynArrayCat3(var Dest: Pointer; Source1, Source2: Pointer; typeInfo: Pointer); (The call from Formcreate) the param typeInfo = nil.

    ReplyDelete
  9. There are a few defects in dynamic array concatenation in XE7. I would just write the code in a different way.

    ReplyDelete
  10. Thanks for all your help guys, I couldn't get it working with update 1 either. I ended up just using tbytes.create and some moves to replace my existing code.

    ReplyDelete

Post a Comment