LoginSignup
2
3

More than 5 years have passed since last update.

C++ > SecureZeroMemory() > 最適化でコンパイラが不要と判断したときに消える ZeroMemory() の代替

Last updated at Posted at 2018-11-13
動作環境
C++ Builder XE4

において @yumetodo 様からコメントをいただきました。
今後検索で見つけたいため、記事としてここに切出します。

ZeroMemory()は最適化で消えるというのは知りませんでした。
代わりのSecureZeroMemory()の存在も知りませんでした。

情報感謝です。

(2018/11/16追記)
@ryoco さんのコメントにてZeroMemory()が最適化で消える場合と消えない場合について教えていただきました。

情報感謝です。

関連情報

Windowsデベロッパーセンター
SecureZeroMemory function

Use this function instead of ZeroMemory when you want to ensure that your data will be overwritten promptly, as some C++ compilers can optimize a call to ZeroMemory by removing it entirely.

ZeroMemory macro

To avoid any undesired effects of optimizing compilers, use the SecureZeroMemory function.

(余談) ZeroMemory macro。マクロ? (ZeroMemory functionでなく)

2
3
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3