Блог пользователя DCSekhara

Автор DCSekhara, история, 4 года назад, По-английски

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..

  • Проголосовать: нравится
  • +14
  • Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

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 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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 года назад, # |
Rev. 3   Проголосовать: нравится +3 Проголосовать: не нравится

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 года назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    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 года назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

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