PTS cast to local loophole for incomplete types

Issue #120 new
Former user created an issue

Originally reported on Google Code with ID 120

UPC 1.3 6.4.3:

  If a non-null pointer-to-shared is cast to a pointer-to-local and the affinity
  of any byte comprising the pointed-to shared object is not to the current
  thread, the result is undefined.

This language prohibits invalid cast-to-local for pointers to remote objects. However,
as currently specified there is a loophole (or at least an ambiguity), for the case
of a pointer-to-shared with incomplete referent type. Such pointers do not "point-to"
any object, and therefore the requirement is trivially satisfied, although we still
need to prohibit such casts.

Consider:

  shared int x;
  int main() {
     shared void *svp = &x;
     void *lvp = (void *)svp; // svp does not point to an object type
     int *lip = (int *)lvp;
     *lip = 7;
     return 0;
  }

The cast in the second line needs to have an undefined result when MYTHREAD!=0, and
most implementations and users probably assume that is the case. However the current
language is not strong enough to prohibit this cast because the referent type is incomplete
- svp does not point to an object, and therefore there are no bytes to fail the affinity
check.

The rule should probably be strengthened with an additional clause to cover pointers
to incomplete types (eg possibly requiring upc_threadof(ptr_expression) to equal the
value of MYTHREAD).

Reported by danbonachea on 2014-03-06 02:53:40

Comments (0)

  1. Log in to comment