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

Fix conversion from long long to int causing truncation. #359

Merged
merged 1 commit into from
Jul 3, 2021

Conversation

IohannRabeson
Copy link
Contributor

@IohannRabeson IohannRabeson commented Jun 21, 2021

I fixed the issue by using llabs() instead of abs() following the suggestion given by the compiler but maybe you do not want to use C99 standard (llabs is available since C99 only).

The warning I got was:

src/brogue/Items.c:3353:23: warning: absolute value function 'abs' given an argument of type 'fixpt' (aka 'long long') but has parameter of type 'int' which may cause truncation of value
      [-Wabsolute-value]
        fixpt m = max(abs(step[0]), abs(step[1]));
                      ^
src/brogue/Items.c:3353:23: note: use function 'llabs' instead
        fixpt m = max(abs(step[0]), abs(step[1]));
                      ^~~
                      llabs

Copy link
Owner

@tmewett tmewett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C99 is what we target - thanks very much!

The error I got verbatim was:
src/brogue/Items.c:3353:23: warning: absolute value function 'abs' given an argument of type 'fixpt' (aka 'long long') but has parameter of type 'int' which may cause truncation of value
      [-Wabsolute-value]
        fixpt m = max(abs(step[0]), abs(step[1]));
                      ^
src/brogue/Items.c:3353:23: note: use function 'llabs' instead
        fixpt m = max(abs(step[0]), abs(step[1]));
                      ^~~
                      llabs
@tmewett tmewett changed the base branch from master to release July 3, 2021 18:48
@tmewett tmewett merged commit 60770b3 into tmewett:release Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants