cpp_weekly icon indicating copy to clipboard operation
cpp_weekly copied to clipboard

Finding memory bugs at compile time

Open lefticus opened this issue 4 months ago • 2 comments

https://compiler-explorer.com/z/jvPPTdsfK

Requires gcc with -O3 and Sanitizers enabled to find this at compile-time.

lefticus avatar Sep 08 '25 20:09 lefticus

Hi Jason,

Strange, adding undefined to fsanitize option silences the warning: https://compiler-explorer.com/z/fesP7Kjxq

Regards

Dharmesh946 avatar Sep 10 '25 08:09 Dharmesh946

This kind of warning is being emitted from the backend (optimizer). Turning on the sanitizers disables certain optimizations so that the runtime can catch them, so the optimizer no longer sees the issue.

lefticus avatar Oct 01 '25 21:10 lefticus