# error[E0080]: constant evaluation error: division by zero

- **ID:** `rust/e0080-constant-evaluation-error-divide-by-zero`
- **Domain:** rust
- **Category:** const-eval
- **Error Code:** `E0080`
- **Verification:** ai_generated
- **Fix Rate:** 95%

## Root Cause

A constant expression performs division or modulo by zero at compile time.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.63.0 | active | — | — |
| 1.66.0 | active | — | — |
| 1.70.0 | active | — | — |

## Workarounds

1. **Ensure the divisor is non-zero by using a conditional: `const DIV: u32 = if DENOM != 0 { NUM / DENOM } else { 0 };`** (95% success)
   ```
   Ensure the divisor is non-zero by using a conditional: `const DIV: u32 = if DENOM != 0 { NUM / DENOM } else { 0 };`
   ```
2. **Use checked arithmetic: `const RESULT: Option<u32> = NUM.checked_div(DENOM);`** (90% success)
   ```
   Use checked arithmetic: `const RESULT: Option<u32> = NUM.checked_div(DENOM);`
   ```

## Dead Ends

- **Using `unsafe` to bypass the check in const context** — `unsafe` is not allowed in const contexts; compiler rejects it. (100% fail)
- **Changing the divisor to a variable to defer evaluation to runtime** — If the divisor is still zero at runtime, it causes a panic; compile-time check is bypassed but runtime error remains. (70% fail)
