Skip to content

Add a detection for narrowing transformations of primitive values #2030

Open
@CaelmBleidd

Description

@CaelmBleidd

Description

We have functionality that checks whether some addition or multiplication causes overflow. Seems like it doesn't reflect specifications (see this comment), so after a discussion with @Markoutte we agreed to change this behaviour in the following way:

  1. Let's make these checks for addition and multiplication for integer/long overflow only (just like Math.addExact)
  2. For all other operations this check should be processed only when narrowing transformation is applied. To do so, we have to implement a check in a cast function that makes sure that the value before the cast is in the bounds of a type after cast.

Expected behavior

Detect overflow for integer and long values, narrowing transformation for all primitive types.

Environment

There is no specific environment.

Potential alternatives

Can be discussed depending on what users expect.

Context

There is no additional context.

Metadata

Metadata

Assignees

Labels

comp-symbolic-engineIssue is related to the symbolic execution enginectg-enhancementNew feature, improvement or change request

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions