Skip to content

Unexpected result when calling count intrinsics with zero #6702

Closed
@adpaco-aws

Description

@adpaco-aws

CBMC version: 5.50.0
Operating system: Ubuntu 20.04
Exact command line resulting in the issue: cbmc example.c, where example.c is

#include <assert.h>

int main() {
    unsigned char var = 0;
    assert(__builtin_clz(var) == 8);
}

What behaviour did you expect: Successful verification
What happened instead: Verification failed.
The result is unexpected because the commit that originally added support says "The result is always defined, even for zero (where the result is the bit width)". A similar thing happens if __builtin_clz is used instead.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions