Yes, because, as all C newbies can easily explain to you, the general rule of thumb is that undefined behavior should be treated as a fault and thus should be handled as a bug.
Hence, your question reads as "Would you consider a bug to be safe?".
In case of integer division, you simply need to check that the divisor is not zero prior to executing the division. Done.
People new to C hear about UB, resolve to not do that, and that seems fine.
People not new to C have noticed that so many constructs are UB as to make it infeasible in practice that any given codebase will be free of UB.
What makes C a fundamentally unsafe language is that conceptually minor errors have unspecified consequences of unbounded magnitude, limited to no compile time detection of said errors, and that even builtins like + are specified to compile successfully into nonsense in some contexts.
Integer operations can be defined to be safe. Whatever integers you pass to your maths operation, you get an unsurprising integer back.
What the language does in the presence of your bug is definitely part of the safety properties of the language.
> What makes C a fundamentally unsafe language is that conceptually minor errors have conceptually unspecified consequences of unbounded magnitude.
There, fixed that for you.
Everybody knows that these scary stories can happen (even though almost nobody has seen them happen in the wild). But for the most part they should be seen as a combination of (typically, obviously) buggy code and compiler optimizer defects, rather than fundamental defects of the language.
> Integer operations can be defined to be safe. Whatever integers you pass to your maths operation, you get an unsurprising integer back.
There is at least 1 arithmetics teacher disagreeing with you.
There is no point, and let me scream again NO FR**G POINT, for a zero divide to return zero. I want it to crash.
And I consider it a compiler defect if the compiler proves that a zero division is happening and proceeds to do a strange optimization instead of reporting it.
It's a fine line to walk though, since there is also the case of legitimately assuming that it doesn't happen, and not emitting the code that triggers the crash. There probably should be compiler knobs to tune the behaviour.
It's explicitly left undefined.
> Would you consider that safe?
Yes, because, as all C newbies can easily explain to you, the general rule of thumb is that undefined behavior should be treated as a fault and thus should be handled as a bug.
Hence, your question reads as "Would you consider a bug to be safe?".
In case of integer division, you simply need to check that the divisor is not zero prior to executing the division. Done.