Skip to content

Proposal: Throw on division by zero #670

Closed
@chriseth

Description

Division by zero currently behaves exactly like division by zero on the EVM: It results in zero.

This could be changed into throwing an exception, just like array access out of bounds and other cases.

Do we want to break backwards compatibility to add this feature?

The check will of course be optimized away for division by constants. An improved optimizer (it cannot do it yet) could also optimize it away if the developer checked for zero just prior to the division. The downside of the comparison is also that block-level optimization cannot be done anymore.

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions