Skip to content

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

Closed
@awvwgk

Description

@awvwgk

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions