Skip to content

Puzzling strcmp behavior #8173

@gleachkr

Description

@gleachkr

CBMC version: 5.91.0

Operating system: Linux, 22.04.1-Ubuntu

Exact command line resulting in the issue:

cbmc ./minimal-strcmp.c, where minimal-strcmp.c is:

#include <assert.h>
#include <string.h>

int main(int argc, char **argv) {
  if (argc != 2)
    return 1;
  char *command = argv[1];
  assert(strcmp("STORE", command) != 0 || strcmp("STORE", command) == 0);
  return 0;
}

What behaviour did you expect:

I would have expected the assert to pass. It passes if strcmp is replaced by a naive reimplementation.

What happened instead:

** Results:
./minimal-strcmp.c function main
[main.assertion.1] line 8 assertion strcmp("STORE", command) != 0 || strcmp("STORE", command) == 0: FAILURE

I expect I'm doing something dumb - thanks for your patience. But a meta-question here is perhaps how I can know when cbmc is replacing a library function with an internal implementation, if that's what's going on here.

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