Skip to content

Commit

Permalink
expand comment explaining integer exception
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Nov 5, 2019
1 parent 21d284b commit a593b54
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/librustc_mir/interpret/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
let b = self.read_immediate(args[1])?.to_scalar()?;

// Special case: if both scalars are *equal integers*
// and not NULL, their offset is 0.
// and not NULL, we pretend there is an allocation of size 0 right there,
// and their offset is 0. (There's never a valid object at NULL, making it an
// exception from the exception.)
// This is the dual to the special exception for offset-by-0
// in the inbounds pointer offset operation.
// in the inbounds pointer offset operation (see the Miri code, `src/operator.rs`).
if a.is_bits() && b.is_bits() {
let a = a.to_usize(self)?;
let b = b.to_usize(self)?;
Expand Down

0 comments on commit a593b54

Please sign in to comment.