Skip to content

Commit

Permalink
Silence harmless warnings on CHERI by using INT2PTR where appropriate
Browse files Browse the repository at this point in the history
On CHERI, pointers are implemented using unforgeable capabilities that
include bounds and permissions metadata to provide fine-grained spatial
and referential memory safety, as well as revocation by sweeping memory
to provide heap temporal memory safety. In order to ensure round trips
via (u)intptr_t preserve this metadata, (u)intptr_t are themselves
represented as capabilities, not plain integers. In order to catch
programming errors caused by using an integer type other than those to
hold a pointer, CHERI LLVM emits a warning by default whenever a plain
integer is cast directly to a pointer (except for integer constants, so
that idioms like (void *)-1 continue to work), since it is likely the
source of that cast should have been a (u)intptr_t instead. Three
instances of this warning remain when compiling for CHERI (note that
Tcl_SetHashValue internally casts to void *), all of which are harmless;
silence them by using INT2PTR.
  • Loading branch information
jrtc27 authored and kwitaszczyk committed Aug 10, 2023
1 parent 21d0e61 commit 4d8b9b5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion generic/tclExecute.c
Original file line number Diff line number Diff line change
Expand Up @@ -6901,7 +6901,7 @@ TEBCresume(
iterVarPtr = LOCAL(infoPtr->loopCtTemp);
valuePtr = iterVarPtr->value.objPtr;
iterNum = valuePtr->internalRep.longValue + 1;
TclSetLongObj(valuePtr, iterNum);
TclSetLongObj(valuePtr, INT2PTR(iterNum));

/*
* Check whether all value lists are exhausted and we should stop the
Expand Down

0 comments on commit 4d8b9b5

Please sign in to comment.