Skip to content

unsigned integer overflow in format-inl.h #1515

Closed
@federico-busato

Description

@federico-busato

example:
fmt::print("{}, {}\n", 2172.112284689786, 0.18808973381374017);

fmt/format-inl.h:417:51: runtime error: unsigned integer overflow: 11 - 52 cannot be represented in type 'unsigned long'
fmt/format-inl.h:484:53: runtime error: unsigned integer overflow: 18446744073709551607 * 1292913986 cannot be represented in type 'unsigned long'
fmt/format-inl.h:417:35: runtime error: unsigned integer overflow: 1020 - 1023 cannot be represented in type 'unsigned long'

found with -fsanitize=undefined -fsanitize=unsigned-integer-overflow (clang 9)

I'm not sure if it is intentional or not. Reproducible on fmt-6.1.2
It can be also suppressed with __attribute__((no_sanitize("unsigned-integer-overflow")))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions