Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect result for multiplication with out of range int #36648

Closed
suleka96 opened this issue Jun 21, 2022 · 3 comments · Fixed by #37726
Closed

Incorrect result for multiplication with out of range int #36648

suleka96 opened this issue Jun 21, 2022 · 3 comments · Fixed by #37726
Assignees
Labels
Points/3 Equivalent to three days effort Priority/Blocker Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug

Comments

@suleka96
Copy link
Contributor

Description:
$title

Steps to reproduce:

const num1 = -2;
const  num2 = -9223372036854775807;
const int ans = num1 * num2; // ans = -2
@suleka96 suleka96 added Type/Bug Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. labels Jun 21, 2022
@gimantha gimantha added the Points/3 Equivalent to three days effort label Sep 7, 2022
@prakanth97
Copy link
Contributor

prakanth97 commented Sep 8, 2022

The spec did not mention about giving compile-time error for memory overflow.
A module-const-decl declares a compile-time constant. Then, we have to give compile-time error to fix this issue.
https://ballerina.io/spec/lang/2022R1/#section_8.8
https://ballerina.io/spec/lang/master/#section_6.23

const num1 = -1;
const num2 = -9223372036854775808;
const int ans = num2 / num1; // -9223372036854775808

This should also give memory overflow but it gives wrong value. So, the fix has to be done for Multiplicative expression

@pcnfernando
Copy link
Member

We'll have to handle these as such. We already have todos in these functions.
eg:

@github-actions
Copy link

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

@pcnfernando pcnfernando added the Reason/EngineeringMistake The issue occurred due to a mistake made in the past. label Nov 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Points/3 Equivalent to three days effort Priority/Blocker Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug
Projects
Archived in project
5 participants