Skip to content

Compiler warning on Windows (signed/unsigned mismatch) #509

@janogran

Description

@janogran

When compiling blake3 for Windows VS2019, there is a compiler warning caused be the lines below from blake3.c:

// Recurse!
size_t left_n = -1;
size_t right_n = -1;

blake3.c
C:__w\2827\s\Base\src\blake3\blake3.c(306,1): error C2220: the following warning is treated as an error [C:__w\2827\s\work\x64_release\Base\src\Base.vcxproj]
C:__w\2827\s\Base\src\blake3\blake3.c(306,1): warning C4245: 'initializing': conversion from 'int' to 'size_t', signed/unsigned mismatch [C:__w\2827\s\work\x64_release\Base\src\Base.vcxproj]
C:__w\2827\s\Base\src\blake3\blake3.c(307,1): warning C4245: 'initializing': conversion from 'int' to 'size_t', signed/unsigned mismatch [C:__w\2827\s\work\x64_release\Base\src\Base.vcxproj]

If warnings are treated as errors (as they are on my system), the build fails due to this.

Preferred solution:
Initiate left_n and right_n to SIZE_MAX, not -1 (or explicitly cast to size_t)

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