Example: eq4.c

up: index
prev: eq3.c
next: eq5.c

    #include <stdio.h>
    #include <cheriintrin.h>
    #include "capprint.h"
    
    int main()
    {
        int x;
        int *p1 = &x;
        int *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
 exit codes: compile 0 / execute 1 Undefined {ub: "UB053_distinct_aggregate_union_pointer_comparison", loc: "<16:45--16:52>"}
p1 = (@disabled, 0xffffe660 [rwRW,0xffffe660-0xffffe664])
p2 = (@disabled, 0xffffe660 [rwRW,0xffffe660-0xffffe664] (invalid))

cheri_is_equal_exact(p1,p2): false
p1 == p2: true
 
cerberus-cheri
cerberus-cheri-revocation
cerberus-cheri-cornucopia
 p1 = (@99, 0xffffe660 [rwRW,0xffffe660-0xffffe664])
p2 = (@99, 0xffffe660 [rwRW,0xffffe660-0xffffe664] (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 %10 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %2), !dbg !45cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %10 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %2), !dbg !45cheri-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 !45cheri-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 !45cheri-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 !78cheri-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 !78cheri-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 !78cheri-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 !78cheri-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 !78cheri-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 !78cheri-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 !78cheri-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 !78p1 = 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 cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %6 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* nonnull %0, i8 addrspace(200)* %1), !dbg !68p1 = 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