Skip to content

Draft: Fix Realm Pointer UB

Struct members are guaranteed to be ordered as written, but there is no guarantee in any way shape or form of their alignment or layout, so

struct Foo
{
  int x, y;
  
  int get_y() { return &x + 1; }
};

is about as "safe" as

int foo() 
{
  int x;
  char z;
  int y;

  assert(&y == (char *)&x + sizeof(int) + 1); // not guaranteed to be true!
}

Rectify this in Legion::Realm::Point, as highlighted by GCC's -Wstringop-overflow

_deps/legion-src/runtime/legion/region_tree.inl:5614:20: warning: writing 16 bytes into a region of size 4 [-Wstringop-overflow=]
#9 856.9  5614 |           point[i] = coords[i];
#9 856.9       |           ~~~~~~~~~^~~~~~~~~

Merge request reports