Skip to content

Commit a0de244

Browse files
pleay nice with alignment
Signed-off-by: Nikolaj Bjorner <[email protected]>
1 parent d818233 commit a0de244

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/muz/rel/dl_sparse_table.h

+8-5
Original file line numberDiff line numberDiff line change
@@ -338,17 +338,20 @@ namespace datalog {
338338
SASSERT(length + m_small_offset <= 64);
339339
}
340340
table_element get(const char * rec) const {
341-
const uint64_t * ptr = reinterpret_cast<const uint64_t*>(rec + m_big_offset);
342-
uint64_t res = *ptr;
341+
342+
uint64_t res;
343+
memcpy(&res, rec + m_big_offset, sizeof(res));
343344
res >>= m_small_offset;
344345
res &= m_mask;
345346
return res;
346347
}
347348
void set(char * rec, table_element val) const {
348349
SASSERT( (val&~m_mask)==0 ); //the value fits into the column
349-
uint64_t * ptr = reinterpret_cast<uint64_t*>(rec + m_big_offset);
350-
*ptr &= m_write_mask;
351-
*ptr |= val << m_small_offset;
350+
uint64_t cell;
351+
memcpy(&cell, rec + m_big_offset, sizeof(cell));
352+
cell &= m_write_mask;
353+
cell |= val << m_small_offset;
354+
memcpy(rec + m_big_offset, &cell, sizeof(cell));
352355
}
353356
unsigned next_ofs() const { return m_offset+m_length; }
354357
};

0 commit comments

Comments
 (0)