Skip to content

Commit

Permalink
document code modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
paleolimbot committed Aug 1, 2020
1 parent c21504b commit dc5c9bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion data-raw/update-s2.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,17 @@ print_next <- function() {
)
cli::cat_bullet(
"Fix zero-length array warnings under -Wpedantic by inserting __extension__ at the beginning ",
"of expressions declaring them (s2region_coverer.h#251, util/gtl/compact_array.h#124)"
"of expressions declaring them (s2region_coverer.h#271)"
)
cli::cat_bullet(
"Fix compact_array zero-length array warning by disabling inline elements on gcc ",
"(util/gtl/compact_array.h#89)"
)
cli::cat_bullet(
"Fix sanitizer error for compact_array when increasing the size of a zero-length array ",
"by wrapping util/gtl/compact_array.h#396-397 with if (old_capacity > 0) {...}"
)

cli::cat_bullet("Remove extra semi-colon at s2boolean_operation.h#376")
cli::cat_bullet("Remove extra semi-colons because of FROMHOST_TYPE_MAP macro (utils/endian/endian.h#565)")
cli::cat_bullet(
Expand Down
6 changes: 6 additions & 0 deletions inst/include/s2/util/gtl/compact_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ class compact_array_base {
#endif

// Opportunistically consider allowing inlined elements.
// dd: this has to be disabled to pass CRAN checks, since there is a
// (potentially) zero-length array that is not the last element of the class (so
// this can't be silenced using __extension__)
#if defined(_LP64) && defined(__GNUC__) && false
// With 64-bit pointers, our approach is to form a 16-byte struct:
// [5 bytes for size, capacity, is_exponent and is_inlined]
Expand Down Expand Up @@ -393,6 +396,9 @@ class compact_array_base {
value_allocator_type allocator;

T* new_ptr = allocator.allocate(capacity());
// dd: this modification fixes a ASAN/UBSAN error, because
// when old_capacity is 0, Array() is nullptr, which is UB
// for memcpy.
if (old_capacity > 0) {
memcpy(new_ptr, Array(), old_capacity * sizeof(T));
allocator.deallocate(Array(), old_capacity);
Expand Down

0 comments on commit dc5c9bc

Please sign in to comment.