AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Object-Pascal / Delphi-Language D12: NativeInt ( womöglich auch andere ), von "strong alias" zu "weak alias"
Thema durchsuchen
Ansicht
Themen-Optionen

D12: NativeInt ( womöglich auch andere ), von "strong alias" zu "weak alias"

Ein Thema von Rollo62 · begonnen am 23. Feb 2024 · letzter Beitrag vom 1. Mär 2024
 
Rollo62

Registriert seit: 15. Mär 2007
4.239 Beiträge
 
Delphi 12 Athens
 
#5

AW: D12: NativeInt ( womöglich auch andere ), von "strong alias" zu "weak alias"

  Alt 26. Feb 2024, 06:59
Wenn ich alle Warnings einschalte, was ich liebend gerne so machen würde, kommen auch solche Dinge hoch, z.B. aus Spring.pas:

Delphi-Quellcode:
  Int24 = packed record //<== unsafe type Int24
  case Integer of
    0: (Low: Word; High: Byte);
    1: (Bytes: array[0..2] of Byte);
  end;
Zitat:
W1046 Unsafe type '%s%s%s' (Delphi)

You have used a data type or operation for which static code analysis cannot prove that it does not overwrite memory. For example, you might receive this warning if you declare something as absolute. Such code can be considered a security risk.
wie gehe ich denn damit um?
Meine Vermutung, dass es einfach an den fehlenden Bytes liegen sollte trifft nicht zu:

Delphi-Quellcode:
  
  Int24 = packed record //<== Wirft das Warning genauso, obwohl der Record überall 4-Byte sein sollte
  case Integer of
    0: (Low: Word; High, Pinky, Ponky: Byte);
    1: (Bytes: array[0..3] of Byte);
  end;
Ich denke mal, dass man das Warnung an der Stelle einfach abschalten sollte, oder wie würdet ihr das machen?

Delphi-Quellcode:
  {$WARN UNSAFE_TYPE OFF}
  Int24 = packed record
  case Integer of
    0: (Low: Word; High: Byte);
    1: (Bytes: array[0..2] of Byte);
  end;
  {$WARN UNSAFE_TYPE ON}
Das Warning hat aber auch einen Sinn und sollte eigentlich dort kommen, wo es benutzt wird.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:19 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz