Example: const0.c

up: index
prev: perms1.c
next: const1.c

    #include <stdio.h>
    #include "capprint.h"
    
    int main()
    {
        const char *c="foo";
        char *w = (char*)c;
    
        fprintf(stderr,"c=%" PTR_FMT ", w=%" PTR_FMT "\n", sptr((void*)c), sptr((void*)w));
        
        *w='\0';    
        fprintf(stderr,"passed\n");
    }

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: "UB033_modifying_string_literal", loc: "<11:5--11:12>"}
c=(@disabled, 0xfffff23e [rR,0xfffff23e-0xfffff242]), w=(@disabled, 0xfffff23e [rR,0xfffff23e-0xfffff242])
 
cerberus-cheri
cerberus-cheri-revocation
cerberus-cheri-cornucopia
 exit codes: compile 0 / execute 1 Undefined {ub: "UB033_modifying_string_literal", loc: "<11:5--11:12>"}
c=(@18, 0xfffff23e [rR,0xfffff23e-0xfffff242]), w=(@18, 0xfffff23e [rR,0xfffff23e-0xfffff242])
 
clang-riscv-O3-bounds-subobject-safe exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability permission fault caused by register cs4.
main () at tests/cheri/const0.c:11
11 *w='\0';
#0 main () at tests/cheri/const0.c:11
w = <optimized out>
c = <optimized out>


c=0x100685 [rR,0x100685-0x100689], w=0x100685 [rR,0x100685-0x100689]
 
clang-riscv-O0-bounds-subobject-safe
clang-riscv-O0-bounds-aggressive
clang-riscv-O0-bounds-very-aggressive
clang-riscv-O0-bounds-everywhere-unsafe
 exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability permission fault caused by register ca2.
0x0000000000102022 in main () at tests/cheri/const0.c:11
11 *w='\0';
#0 0x0000000000102022 in main () at tests/cheri/const0.c:11
c = 0x100685 [rR,0x100685-0x100689] "foo"
w = 0x100685 [rR,0x100685-0x100689] "foo"


c=0x100685 [rR,0x100685-0x100689], w=0x100685 [rR,0x100685-0x100689]
 
clang-riscv-O3-bounds-conservative c=0x10070d [rR,0x10070d-0x100711], w=0x10070d [rR,0x10070d-0x100711]
passed
 
clang-riscv-O0-bounds-conservative
clang-riscv-O0-bounds-references-only
 exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability permission fault caused by register ca2.
0x0000000000101ff2 in main () at tests/cheri/const0.c:11
11 *w='\0';
#0 0x0000000000101ff2 in main () at tests/cheri/const0.c:11
c = 0x100685 [rR,0x100685-0x100689] "foo"
w = 0x100685 [rR,0x100685-0x100689] "foo"


c=0x100685 [rR,0x100685-0x100689], w=0x100685 [rR,0x100685-0x100689]
 
clang-morello-O3-bounds-subobject-safe exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability permission fault.
main () at tests/cheri/const0.c:11
11 *w='\0';
#0 main () at tests/cheri/const0.c:11
w = 0x100885 [rR,0x100885-0x100889] "foo"
c = 0x100885 [rR,0x100885-0x100889] "foo"


c=0x100885 [rR,0x100885-0x100889], w=0x100885 [rR,0x100885-0x100889]
 
clang-morello-O0-bounds-subobject-safe
clang-morello-O0-bounds-aggressive
clang-morello-O0-bounds-very-aggressive
clang-morello-O0-bounds-everywhere-unsafe
 exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability permission fault.
0x0000000000110ea4 in main () at tests/cheri/const0.c:11
11 *w='\0';
#0 0x0000000000110ea4 in main () at tests/cheri/const0.c:11
c = 0x100885 [rR,0x100885-0x100889] "foo"
w = 0x100885 [rR,0x100885-0x100889] "foo"


c=0x100885 [rR,0x100885-0x100889], w=0x100885 [rR,0x100885-0x100889]
 
clang-morello-O3-bounds-conservative c=0x100984 [rR,0x100984-0x100988], w=0x100984 [rR,0x100984-0x100988]
passed
 
clang-morello-O0-bounds-conservative
clang-morello-O0-bounds-references-only
 exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability permission fault.
0x0000000000110e74 in main () at tests/cheri/const0.c:11
11 *w='\0';
#0 0x0000000000110e74 in main () at tests/cheri/const0.c:11
c = 0x100885 [rR,0x100885-0x100889] "foo"
w = 0x100885 [rR,0x100885-0x100889] "foo"


c=0x100885 [rR,0x100885-0x100889], w=0x100885 [rR,0x100885-0x100889]
 
gcc-morello-O3 exit codes: compile 0 / execute 137 c=0x415e40 [rR,0x415e40-0x415e44], w=0x415e40 [rR,0x415e40-0x415e44]
 
gcc-morello-O0 exit codes: compile 0 / execute 137 c=0x4162d0 [rR,0x4162d0-0x4162d4], w=0x4162d0 [rR,0x4162d0-0x4162d4]