I'm wondering whether there's something to do to prevent UB

Revision en4, by OtterZ, 2025-10-18 14:03:04

UB(short form of "Undefined Behavior",means something not lead to compile error but not defined) is easy to be ignored. In Codeforces the judge will report UB but in some contest UB may lead to running in a right way in DEVC++ or other local compilor,making it harder to prevent.

I've found that -Wall -Wextra won't report them all and '-fsanitize=undefined',which was mentioned and recommanded in articles I can find in Bing,is not supported in original Devc++(report "Cannot find '-lubsan'") or g++ in Linux,making it unable to be used in contests like CNOI or even CSP.I want to know if there's any other way to prevent in original local compilor.(Huge thanks if there's someone who can provide me with his experience about preventing UB in CNOI or CSP or NOIP).

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English OtterZ 2025-10-18 14:03:04 829 (published)
en3 English OtterZ 2024-09-24 09:47:58 6 Tiny change: 'For $a_i \exists N,\sum a_' -> 'For $a_i \in N,\sum a_'
en2 English OtterZ 2024-09-24 09:47:45 1 Tiny change: 'a_i \exist N,\sum a_' -> 'a_i \exists N,\sum a_'
en1 English OtterZ 2024-09-24 09:47:32 473 Initial revision (saved to drafts)