DCSekhara's blog

By DCSekhara, history, 4 years ago, In English

Can someone tell what are the compilation flags that you use in Windows-10 and also the compiler which you use. (The main thing I want is how to catch out of arrays accesses and similar stuff and catching exceptions..). You may also share your IDE if you want . Thanks Friends..

  • Vote: I like it
  • +14
  • Vote: I do not like it

»
4 years ago, # |
  Vote: I like it +3 Vote: I do not like it

I have been using this, pretty useful, you should check it out (although some flags might not be compatible with Windows).

I have also found this and this, haven't tried those myself but I think you should check those out as well.

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

thanks this worked

-Wall -Wextra -pedantic -std=c++17 -O3 -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC

it was finding the out-of bounds errors

»
4 years ago, # |
Rev. 3   Vote: I like it +3 Vote: I do not like it

I use geany in linux and here are my two compile commands:

  • Compile (F8): g++ -std=c++11 -O2 -Wall -Wextra -Wno-unused-result -Wno-char-subscripts -Wshadow -Wfloat-equal -Wconversion -Wformat-signedness -Wvla -Wduplicated-cond -Wlogical-op -Wredundant-decls -o "%e" "%f"
  • Build (F9): g++ -std=c++11 -O0 -Wall -Wextra -Wno-unused-result -Wno-char-subscripts -Wshadow -Wfloat-equal -Wconversion -Wformat-signedness -Wvla -Wduplicated-cond -Wlogical-op -Wredundant-decls -ggdb3 -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fsanitize=undefined,address,float-divide-by-zero,float-cast-overflow -fno-omit-frame-pointer -fno-optimize-sibling-calls -fstack-protector-all -fno-sanitize-recover=all -o "%e" "%f"
  • »
    »
    4 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    yeah I also use similar ones in geany in linux.

    But I also wanted to configure my windows for coding and when I tried to use fsanitize flags in windows it gave some errors(some lubsan ... ) for which i didn't find a way to get rid of them.

    Edit: Sorry You are right . For a normal C-Style Array it is not able to find the Error. So , what is the way of catching runtime out of bound errors in Windows?

»
4 years ago, # |
  Vote: I like it +5 Vote: I do not like it

I use g++ version 9.2.0 and I use these compilation flags

-std=c++17 % -O2 -Wall -Wextra -Wno-sign-conversion -Wshadow -DLOCAL

But I don't know why -fsanitize does not work.

-fsanitize=undefined,address