Skip to content

to_string overflows on -huge(1)-1 #666

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

Closed
awvwgk opened this issue Jul 20, 2022 · 0 comments · Fixed by #667
Closed

to_string overflows on -huge(1)-1 #666

awvwgk opened this issue Jul 20, 2022 · 0 comments · Fixed by #667
Labels
bug Something isn't working

Comments

@awvwgk
Copy link
Member

awvwgk commented Jul 20, 2022

Description

The following test will currently fail (tested with Intel Fortran):

  subroutine test_string_i8(error)
    use stdlib_kinds, only : i8 => int64
    use stdlib_strings, only : to_string
    !> Error handling
    type(error_type), allocatable, intent(out) :: error

    call check(error, to_string(-huge(1_i8) - 1_i8), "-9223372036854775808")
  end subroutine test_string_i8

Fails due to abs at

Expected Behaviour

Correctly serialize -huge(1)-1.

Version of stdlib

0.2.0, f98f3d3

Platform and Architecture

any

Additional Information

Found when adopting to_string in TOML Fortran: toml-f/toml-f@d3ffce6 (#93)
Potential fix in fortran-lang/test-drive#21

@awvwgk awvwgk added the bug Something isn't working label Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant