Question Details

No question body available.

Tags

c++ compiler-warnings

Answers (1)

Accepted Answer Available
Accepted Answer
July 29, 2026 Score: 1 Rep: 51,341 Quality: Medium Completeness: 60%

As mentioned by cigien, you can use -fsanitize=undefined with gcc. Then gcc produces:

/app/example.cpp:7:60: runtime error: signed integer overflow: 4096 * 1048576 cannot be represented in type 'int'

Unfortunately, msvc doesn't have an equivalent flag that can directly detect this.