Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link https://codeforces.com/10years. ×

### Bhj2001's blog

By Bhj2001, history, 4 weeks ago, ,
 #pragma GCC optimize ("trapv") // kills the program on integer overﬂows (but is really slow).


This helps a lot in testing. If a solution fails on a particular test case this can help in finding the bug.
This works on my computer but does not work on Codeforces.
Is there an alternative to this on online judges?

• +38

 » 4 weeks ago, # |   +23 This is very useful option indeed, just remember, that it does not work with unsigned integers and with casts
 » 4 weeks ago, # | ← Rev. 2 →   +17 I compile with these flags and one of them turns on checking for overflows (but slows the program down too). This won't likely help you when submitting to an online judge :(g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG
 » 4 weeks ago, # | ← Rev. 2 →   +17 On Codeforces, you can submit with the compiler "Clang++ 17 Diagnostics", which have much more checking than just integer overflow error. However, because test cases on Codeforces are large, you might get time limit exceeded before getting to the desired test case. See also: Catching silly mistakes with GCC — Codeforces (including tips on how to check integer overflow, array out of bound error, check for precondition in STL algorithm, turn on warnings, etc.)