In order to have a better protection against UB cases like:
#include <stdio.h>
int f(){
int x;
return x;
}
int main()
{
f();
while(1);
return 0;
}
I've updated my GCC today so I could use ubsan. My current version is 5.3.0 according to gcc --version
. I thought ubsan will be added by this update, but it seems that it was not because after compiling with C:\Users\my_name\Desktop>gcc -fsanitize=undefined a.c
this is what I get:
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot fin d -lubsan
Now, I've seen this post but the OS is Ubuntu 15.04
and I use Win 8.1
so that didn't help me. One of the comments here says:
You will need to install the libubsan package.
but I don't know if it was meant for windows/ubuntu
, and even if it was for windows
users, I don't understand how to do it.
edit: I tried also compiling gcc -fno-sanitize=all a.c
(there are a lot of options in here) and this compiled with no warning, so I guess GCC
recognizes the sanitizer somehow (because it compiled OK) but rejects my original compilation try for some reason
For GCC on x86_64 sanitizer runtime libraries (including -lubsan
) are only supported for Linux, OSX, FreeBSD and Solaris (see https://github.com/gcc-mirror/gcc/blob/master/libsanitizer/configure.tg for details). So unfortunately you can not yet use UBsan on Windows.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With