i m using GCC compiler which i downloaded from here - Download mingw-w64-install.exe (MinGW-w64 - for 32 and 64 bit Windows)
I have a windows 10 machine and am using VS Code’s integrated cmd terminal to compile my main.cpp files. (below is a screenshot attached of my IDE)
My Problem
when i tried to compile my main.cpp file with this GNU flag -fsanitize=undefined
using the below given command :
C:\Users\Humble Fool\Desktop\dummy>g++ main.cpp -g -D_GLIBCXX_DEBUG -fsanitize=undefined -ftrapv
I got this error -
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lubsan
collect2.exe: error: ld returned 1 exit status
but when i used this command :
C:\Users\Humble Fool\Desktop\dummy>g++ main.cpp -g -D_GLIBCXX_DEBUG -ftrapv
the .cpp file compiled properly !
So i figured out that problem is with -fsanitize=undefined
flag.
How Can I fix it ?
Few people on stackoverflow were saying that maybe my compiler doesn’t supports it ! but I have seen a screenshot using g++ compiler (not on windows, probably Linux) and this flag worked with no issue !