Skip to content

Commit

Permalink
Fixing negative remainder offset
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdsupremacist committed Feb 7, 2021
1 parent fafe33d commit 86b8a08
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/Syntax/Implementations/Structure/TupleParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ private protocol ValuePopper { }
extension ValuePopper {

static func pop<T : Collection>(from scanner: Scanner, into pointer: UnsafeMutableRawPointer, followedBy next: T) throws where T.Element == Any.Type {
let byteOffsetNeeded = (MemoryLayout<Self>.alignment - Int(UInt(bitPattern: pointer))) % MemoryLayout<Self>.alignment
var byteOffsetNeeded = (MemoryLayout<Self>.alignment - Int(UInt(bitPattern: pointer))) % MemoryLayout<Self>.alignment
if byteOffsetNeeded < 0 {
byteOffsetNeeded += MemoryLayout<Self>.alignment
}

let pointer = pointer.advanced(by: byteOffsetNeeded)

if let nextType = next.first {
Expand Down

0 comments on commit 86b8a08

Please sign in to comment.