Skip to content

Wanings compiling gunzip.hh on Windows #6

@albert-github

Description

@albert-github

When compiling on Windows with the Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29914 for x64 compiler and enabling warnings I get the warnings:

...\TinyDeflate\gunzip.hh(983): warning C4800: Implicit conversion from 'uint_least64_t' to bool. Possible information loss
...\TinyDeflate\gunzip.hh(983): note: consider using explicit cast or comparison to 0 to avoid this warning
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\stdint.h(34): note: see declaration of 'uint_least64_t'

Changing the lines 983 and 984 from:

            if(header&0x0800) for(;;) { GetBits(8, bool q); if(!q) break; } // NAME: Skip filename if FNAME was present
            if(header&0x1000) for(;;) { GetBits(8, bool q); if(!q) break; } // COMMENT: Skip comment if FCOMMENT was present

to

            if(header&0x0800) for(;;) { GetBits(8, std::uint_least64_t q); if(!q) break; } // NAME: Skip filename if FNAME was present
            if(header&0x1000) for(;;) { GetBits(8, std::uint_least64_t q); if(!q) break; } // COMMENT: Skip comment if FCOMMENT was present

solves the problem, though it might be even better to change them in:

            if(header&0x0800) for(;;) { GetBits(8, std::uint_least64_t q); if(q == 0) break; } // NAME: Skip filename if FNAME was present
            if(header&0x1000) for(;;) { GetBits(8, std::uint_least64_t q); if(q == 0) break; } // COMMENT: Skip comment if FCOMMENT was present

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions