Skip to content

64bit set shift count overflow #827

Closed
@ayfomin

Description

@ayfomin

When we use set type in a scheme with uint64 encoding type:

<set name="FlagsSet" encodingType="uint64">
    <choice name="Bit0" description="Bit 0">0</choice>
    <choice name="Bit35" description="Bit 35">35</choice>
</set>

sbe-all generates CPP code like this:

static bool bit35(const std::uint64_t bits)
{                                           
    return (bits & (1u << 35u)) != 0;
}

which causes warning in gcc:

FlagsSet.h:255:31: warning: left shift count >= width of type [-Wshift-count-overflow]
         return (bits & (1u << 35u)) != 0;

Here is the value of right operand - 35u is greater to the number of bits in the left operand 1u - 32 bits.

Could somebody help to fix it, please?

ex.zip

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