Skip to content

Exception on overflow #796

@phiferd

Description

@phiferd

It would be nice if Solidity, by default, threw an exception for arithmetic overflow, rather than allowing it.

Justification:

  1. Overflow is rarely desired behavior and is commonly cited as a security vulnerability.
    2: Even in cases where overflow is desired behavior, throwing an exception is a far safer failure mode and easier to detect/correct.
    3: The goal of solidity, as I understand it, is to enable the creation of secure and reliable smart contacts. Therefore, although it is of course possible for the developer to include their own checks, including this as a feature of the language will make the common case both simple and more secure.

If this is not achievable, I welcome alternatives that do not require each and every developer to remember these corner cases for each and every arithmetic operation. A solution that states "everybody should do XYZ" will inevitably lead to failures.

I'm am not familiar enough with the code to propose a detailed solution. However, a compiler switch that is on by default and can be disabled for backward compatibility is the sort of approach I was imagining.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions