Decompilation to pure C using Hex-Rays or Ghidra

Yet another piece of advice for those who use Hex-Rays or Ghidra decompilers.

If you recompile pure C code you got from decompiler, you suffer from UB (undefined behaviour) often. Like if a local array hasn't been initalized, but some instruction reads from it. To detect such nasty problems, you can use Valgrind. It saved me many hours/days/weeks of debugging.

(Well, Valgrind is a cool tool for any other uses as well.)

Also, pay close attention to all C/C++ compiler warnings. This is especially important for the code on an edge of UB.

(the post first published at 20220917.)

List of my other blog posts.

Yes, I know about these lousy Disqus ads. Please use adblocker. I would consider to subscribe to 'pro' version of Disqus if the signal/noise ratio in comments would be good enough.