Example: eq5.c

up: index
prev: eq4.c
next: intr0.c

    #include <stdio.h>
    #include <stdint.h>
    #include <cheriintrin.h>
    #include "capprint.h"
    
    int main()
    {
        int x;
        uintptr_t p1 = (uintptr_t)&x;
        uintptr_t p2 = cheri_tag_clear(p1);
    
        fprintf(stderr,"p1 = %" PTR_FMT "\n", sptr((void*)p1));
        fprintf(stderr,"p2 = %" PTR_FMT "\n\n", sptr((void*)p2));
    
        fprintf(stderr,"cheri_is_equal_exact(p1,p2):\t%s\n", cheri_is_equal_exact(p1,p2) ? "true" : "false");
        fprintf(stderr,"p1 == p2:\t\t\t%s\n", p1 == p2 ? "true" : "false");
        fprintf(stderr,"p1 <  p2:\t\t\t%s\n", p1 <  p2 ? "true" : "false");
        fprintf(stderr,"p2 >  p2:\t\t\t%s\n", p1 >  p2 ? "true" : "false");
        fprintf(stderr,"p1 <= p2:\t\t\t%s\n", p1 <= p2 ? "true" : "false");
        fprintf(stderr,"p1 >= p2:\t\t\t%s\n", p1 >= p2 ? "true" : "false");
    }

Experimental data (what does this mean?)

cerberus-cheri-no-pnvi
cerberus-cheri-revocation-no-pnvi
cerberus-cheri-cornucopia-no-pnvi
 p1 = (@disabled, 0xffffe670 [rwRW,0xffffe670-0xffffe674])
p2 = (@disabled, 0xffffe670 [rwRW,0xffffe670-0xffffe674] (invalid))

cheri_is_equal_exact(p1,p2): false
p1 == p2: true
p1 < p2: false
p2 > p2: false
p1 <= p2: true
p1 >= p2: true
 
cerberus-cheri
cerberus-cheri-revocation
cerberus-cheri-cornucopia
 p1 = (@99, 0xffffe670 [rwRW,0xffffe670-0xffffe674])
p2 = (@99, 0xffffe670 [rwRW,0xffffe670-0xffffe674] (invalid))

cheri_is_equal_exact(p1,p2): false
p1 == p2: true
p1 < p2: false
p2 > p2: false
p1 <= p2: true
p1 >= p2: true
 
clang-riscv-O3-bounds-subobject-safe cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %9 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %2), !dbg !44cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %9 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %2), !dbg !44cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %9 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %2), !dbg !44cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %13 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %2), !dbg !77cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %13 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %2), !dbg !77cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %13 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %2), !dbg !77cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %13 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %2), !dbg !77cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %13 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %2), !dbg !77cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %13 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %2), !dbg !77cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %13 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %2), !dbg !77cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %13 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %2), !dbg !77p1 = 0x3fffdfff1c [rwRW,0x3fffdfff1c-0x3fffdfff20]
p2 = 0x3fffdfff1c [rwRW,0x3fffdfff1c-0x3fffdfff20] (invalid)

cheri_is_equal_exact(p1,p2): false
p1 == p2: true
p1 < p2: false
p2 > p2: false
p1 <= p2: true
p1 >= p2: true
 
clang-riscv-O3-bounds-conservative p1 = 0x3fffdfff1c [rwRW,0x3fffdfff1c-0x3fffdfff20]
p2 = 0x3fffdfff1c [rwRW,0x3fffdfff1c-0x3fffdfff20] (invalid)

cheri_is_equal_exact(p1,p2): false
p1 == p2: true
p1 < p2: false
p2 > p2: false
p1 <= p2: true
p1 >= p2: true
 
clang-riscv-O0-bounds-conservative
clang-riscv-O0-bounds-references-only
clang-riscv-O0-bounds-subobject-safe
clang-riscv-O0-bounds-aggressive
clang-riscv-O0-bounds-very-aggressive
clang-riscv-O0-bounds-everywhere-unsafe
 p1 = 0x3fffdfff6c [rwRW,0x3fffdfff6c-0x3fffdfff70]
p2 = 0x3fffdfff6c [rwRW,0x3fffdfff6c-0x3fffdfff70] (invalid)

cheri_is_equal_exact(p1,p2): false
p1 == p2: true
p1 < p2: false
p2 > p2: false
p1 <= p2: true
p1 >= p2: true
 
clang-morello-O3-bounds-subobject-safe p1 = 0xfffffff7feec [rwRW,0xfffffff7feec-0xfffffff7fef0]
p2 = 0xfffffff7feec [rwRW,0xfffffff7feec-0xfffffff7fef0] (invalid)

cheri_is_equal_exact(p1,p2): false
p1 == p2: true
p1 < p2: false
p2 > p2: false
p1 <= p2: true
p1 >= p2: true
 
clang-morello-O3-bounds-conservative p1 = 0xfffffff7fefc [rwRW,0xfffffff7fefc-0xfffffff7ff00]
p2 = 0xfffffff7fefc [rwRW,0xfffffff7fefc-0xfffffff7ff00] (invalid)

cheri_is_equal_exact(p1,p2): false
p1 == p2: true
p1 < p2: false
p2 > p2: false
p1 <= p2: true
p1 >= p2: true
 
clang-morello-O0-bounds-conservative
clang-morello-O0-bounds-references-only
clang-morello-O0-bounds-subobject-safe
clang-morello-O0-bounds-aggressive
clang-morello-O0-bounds-very-aggressive
clang-morello-O0-bounds-everywhere-unsafe
 p1 = 0xfffffff7ff5c [rwRW,0xfffffff7ff5c-0xfffffff7ff60]
p2 = 0xfffffff7ff5c [rwRW,0xfffffff7ff5c-0xfffffff7ff60] (invalid)

cheri_is_equal_exact(p1,p2): false
p1 == p2: true
p1 < p2: false
p2 > p2: false
p1 <= p2: true
p1 >= p2: true
 
gcc-morello-O3 p1 = 0x7fffffdc [rwRW,0x7fffffdc-0x7fffffe0]
p2 = 0x7fffffdc [rwRW,0x7fffffdc-0x7fffffe0] (invalid)

cheri_is_equal_exact(p1,p2): false
p1 == p2: true
p1 < p2: false
p2 > p2: false
p1 <= p2: true
p1 >= p2: true
 
gcc-morello-O0 p1 = 0x7fffffbc [rwRW,0x7fffffbc-0x7fffffc0]
p2 = 0x7fffffbc [rwRW,0x7fffffbc-0x7fffffc0] (invalid)

cheri_is_equal_exact(p1,p2): false
p1 == p2: true
p1 < p2: false
p2 > p2: false
p1 <= p2: true
p1 >= p2: true