Autor Beitrag
Nano-Ware
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 394
Erhaltene Danke: 7



BeitragVerfasst: Mi 04.04.12 12:14 
Hey,

ich habe heute das erste Mal den Debugger benutzt und bin schrittweise durch die Anwendung durch. Währenddessen wollte ich den Wert der Variable a sehen, nur im Debuggerfenster bei Beobachtung hat a den Wert "E2171 Auf Variable 'a' kann wegen Optimierung nicht zugegriffen werden". Warum und wie bekomm ich das hin, dass a angezeigt wird?


Moderiert von user profile iconNarses: Topic aus Sonstiges (Delphi) verschoben am Mi 04.04.2012 um 16:05
Nersgatt
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1581
Erhaltene Danke: 279


Delphi 10 Seattle Prof.
BeitragVerfasst: Mi 04.04.12 12:28 
Dann hat der Compiler an der Stelle Dein a wegoptimiert, weil es an der Stelle nicht benötigt wird.
Zeig mal einen Quellcodeausschnitt.

_________________
Gruß, Jens
Zuerst ignorieren sie dich, dann lachen sie über dich, dann bekämpfen sie dich und dann gewinnst du. (Mahatma Gandhi)
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Mi 04.04.12 12:56 
Optimierung abschalten

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS
Nano-Ware Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 394
Erhaltene Danke: 7



BeitragVerfasst: Mi 04.04.12 13:56 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.FormCreate(Sender: TObject);
var
  I: Integer;
  a : Integer;
begin

  for I := 0 to 100 do
  begin

    a := i*i;

  end;



end;


Halt eben ein Testcode mit Schleife.
Nersgatt
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1581
Erhaltene Danke: 279


Delphi 10 Seattle Prof.
BeitragVerfasst: Mi 04.04.12 14:08 
Jupp, auf den Wert von a wird gar nicht zugegriffen. Der Compiler erkennt das und wirft es raus.
Wenn Du in die Schleife z.B. ein Label1.Caption := IntToStr(a); einfügst, würde es drin bleiben.

_________________
Gruß, Jens
Zuerst ignorieren sie dich, dann lachen sie über dich, dann bekämpfen sie dich und dann gewinnst du. (Mahatma Gandhi)