This depends on the context in which you do a division by 0. If you do it in a context that only needs the expression to be evaluated at run-time, then it's undefined behavior:
void f() { int a = 9 / 0; // UB }
Note that UB means anything can happen, including the compiler noticing that the code is buggy, and refusing to compile it. In practice, when you divide a constant by 0, the compiler is likely to issue at least a warning.
If it happens in a constexpr or consteval context, then the behavior is well-defined, and the compiler is required to not compile the code:
constexpr void f() { int a = 9 / 0; // error, never produces a valid result }
or
void f() { constexpr int a = 9 / 0; // error }
The primary reason for this is that all behavior is well defined at compile time, and so there is no UB in these contexts.
int main() { int a = 9 / 0; }int x= 5/3;then typically the division is not made at runtime