Skip to content

CBMC 5.95.1 misses an error for program with cast to pointer #8200

Open

Description

@christina1993

CBMC 5.95.1 seemingly misses the assertion violation in the following short program that I previously wrote:

#include <assert.h>
int main(){
  char* x = "";
  char* ptr = (char *) 0x55a8a2e6b007;
  assert(ptr != x);
}

When executing cbmc without any options I get:

CBMC version 5.95.1 (cbmc-5.95.1) 64-bit x86_64 linux
Parsing my_test.c
Converting
Type-checking my_test
Generating GOTO Program
Adding CPROVER library (x86_64)
Removal of function pointers and virtual functions
Generic Property Instrumentation
Running with 8 object bits, 56 offset bits (default)
Starting Bounded Model Checking
Runtime Symex: 0.000705736s
size of program expression: 24 steps
simple slicing removed 5 assignments
Generated 1 VCC(s), 1 remaining after simplification
Runtime Postprocess Equation: 1.4369e-05s
Passing problem to propositional reduction
converting SSA
Runtime Convert SSA: 0.000148792s
Running propositional reduction
Post-processing
Runtime Post-process: 3.892e-06s
Solving with MiniSAT 2.2.1 with simplifier
128 variables, 0 clauses
SAT checker inconsistent: instance is UNSATISFIABLE
Runtime Solver: 1.7748e-05s
Runtime decision procedure: 0.000196021s

** Results:
my_test.c function main
[main.assertion.1] line 6 assertion invalid_char_pt != x4: SUCCESS

** 0 of 1 failed (1 iterations)
VERIFICATION SUCCESSFUL

0x55a8a2e6b007 is a value I actually encountered for x in a previous run on my machine, so the assertion is indeed unsafe.

Thanks in advance

Activity

  1. tautschnig commented on Feb 9, 2024

    @tautschnig
    Collaborator

    Casting an integer to a pointer is implementation-defined behaviour in C. So, yes, it would be great if CBMC considered all possible implementations, but our pointer model doesn't currently do this. We have ideas on how we might fix this, but not clear timeline on when that'll be complete.

  2. added 2 commits that reference this issue on Apr 8, 2026
    d05e05c
    387d3bd
  3. added 13 commits that reference this issue on Jun 25, 2026
    0c41377
    b959b58
    b7611df
    6e409dc
    9187115
    0d865ce
    e44d9eb
    ad36c47
    0338aae
    3c74878
    854e5d9
    b937882
    c2e1e74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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