I am new to C and wondering how to properly build primitive functions in order to handle errors. Take for example the following function:
bool
testIfEqual(int a, int b) {
return a == b;
}
Wondering if there are certain classes of errors that the compiler wont detect that this function should account for if it were to be robust.
Things like buffer overflows, max integer size, perhaps something that can sneak between the cracks of the type safety somehow.
Basically wondering if there are certain classes of errors for the primitive operators that should be accounted for in a robust application:
- ==
- +
- -
- / (divide by zero)
- *
- &&
- ||
- &
- |
- >>
- <<
- >
- <
- >=
- <=
- !=
- !
Not looking for a complete list of stuff, but just general guidelines on best practices for covering standard errors these operators may be involved in.
I would typically write an application without ever thinking of errors that these things could be involved in, but if you have a function like above, wondering what errors it might create in C so I can cover them. Making sure I'm not missing anything.