Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Extra libraries, Code snippets, applications etc. » C++ language problems and code snippets » Capture division by zero
Re: Capture division by zero [message #55206 is a reply to message #55184] Sun, 18 October 2020 21:21 Go to previous messageGo to previous message
Klugier is currently offline  Klugier
Messages: 1099
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello Koldo,

From my personal experience you should identify all the places when division by zero can occurred and handle error separately. To find all places you should use static analyzer. I saw that cppcheck and clang-tidy have tools to detect problem such this.

I also suggest to cover each of the code that can cause division by zero problem with unit tests. Some time ago I added plugin/gtest to the bazaar to make code more bulletproof. One of the reason programmers use unit tests is to test corner cases easily.

Resources:
- https://sourceforge.net/p/cppcheck/wiki/ListOfChecks/ (Just search of division)

Klugier


U++ - one framework to rule them all.

[Updated on: Sun, 18 October 2020 21:40]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Read a text file and assign values to variables int and double
Next Topic: compiling issue with Clang
Goto Forum:
  


Current Time: Wed Apr 30 16:08:34 CEST 2025

Total time taken to generate the page: 0.01296 seconds