clangupc / clang-upc

Clang UPC Front-End
https://clangupc.github.io/
Other
16 stars 5 forks source link

[SPEC 1.3] Relational operators (<,>,<=,>=) applied to a pointer-to-shared incomplete type are invalid #18

Closed gary-funck closed 11 years ago

gary-funck commented 11 years ago

The UPC 1.3 specification clarifies the behavior of relational operators applied to a PTS where the target type of the PTS is an incomplete type [including (shared void *)]. http://code.google.com/p/upc-specification/issues/detail?id=104 [^]

If the relational operation is defined, then its effect is equivalent to testing the result of PTS subtraction of the two operands.

Clang UPC should be changed to conform to the definition stated above.

gary-funck commented 11 years ago

Test case 1.

// Tester for "issue 104" compliance: PTS and relational ops
// Copyright 2013, The Regents of the University of California,
// through Lawrence Berkeley National Laboratory (subject to
// receipt of any required approvals from U.S. Dept. of Energy)
// See the full license terms at
//       http://upc.lbl.gov/download/dist/LICENSE.TXT

shared int x;

int main(void) {
  shared int  *p = &x;
  shared void *q = &x;

  // This comparision is prohibited:
  return (p < q);
}
gary-funck commented 11 years ago

Test case 2.

// Tester for "issue 104" compliance: PTS and relational ops
// Copyright 2013, The Regents of the University of California,
// through Lawrence Berkeley National Laboratory (subject to
// receipt of any required approvals from U.S. Dept. of Energy)
// See the full license terms at
//       http://upc.lbl.gov/download/dist/LICENSE.TXT

shared int x;
struct foo; // forward decl

int main(void) {
  shared int  *p = &x;
  shared struct foo *q = (shared struct foo *)&x;

  // This comparision is prohibited:
  return (p < q);
}
swatanabe commented 11 years ago

I already tried to handle this, but it looks like a missed a few cases.