Clarification: are layout qualifiers allowed in shared scalar declarations?
Originally reported on Google Code with ID 72 ``` Given:
- include <upc.h>
- include <stdio.h>
shared [3] int i; shared [4] struct {int a, b;} s; shared struct S *p_s; shared [5] struct S {int x, y;};
int main(void) { printf ("upc_blocksizeof(i) = %lld\n", (long long)upc_blocksizeof(i)); printf ("upc_blocksizeof(s) = %lld\n", (long long)upc_blocksizeof(s)); printf ("sizeof(*p_s) = %lld\n", (long long)sizeof(*p_s)); printf ("upc_blocksizeof(*p_s) = %lld\n", (long long)upc_blocksizeof(*p_s)); return 0; }
GUPC accepts this without complaint, but does it make sense to specify a layout qualifier in a shared scalar declaration?
The values printed are:
upc_blocksizeof(i) = 3 upc_blocksizeof(s) = 4 sizeof(*p_s) = 8 upc_blocksizeof(*p_s) = 1
Note that in this declaration:
shared [5] struct S {int x, y;};
Neither the shared qualifier nor the layout qualifier [5] are applied to the definition of "struct S".
```
Reported by `gary.funck` on 2012-07-17 22:16:06
Comments (10)
-
Account Deleted -
Account Deleted ``` This issue appears to be closely related to (potentially a duplicate of) Issue 39: Can layout qualifiers applied to shared scalars be eliminated? which was marked Rejected.
As Brian observed in that thread, having a layout qualifier on a scalar allows assigning its address to a pointer-to-shared of compatible layout without the need for a cast. This was cited as useful in situations such as a sentinel in a linked list. ```
Reported by `phhargrove@lbl.gov` on 2012-07-17 22:27:25
-
Account Deleted ``` Set default Consensus to "Low". ```
Reported by `gary.funck` on 2012-08-19 23:26:19 - Labels added: Consensus-Low
-
Account Deleted ``` Change Status to New: Requires review. ```
Reported by `gary.funck` on 2012-08-19 23:37:41 - Status changed: `New`
-
Account Deleted ``` I will handle this one. I do think it is, as suggested by Paul, a duplicate of Issue 39. ```
Reported by `brian.wibecan` on 2012-09-17 15:58:56 - Status changed: `Accepted`
-
Account Deleted ``` Leaving status as "New", pending discussion. ```
Reported by `gary.funck` on 2012-09-17 17:27:19 - Status changed: `New`
-
Account Deleted ``` I just noticed this issue is already explicitly addressed in UPC 1.2, 6.5.1 footnote 16:
"While layout qualifiers are most often seen in array or pointer declarators, they are allowed in all declarators. For example, shared [3] int y is allowed."
Since we seem in agreement this is the right behavior, and the clarification already exists in the spec, I think that means this issue can be closed with NoChange. ```
Reported by `danbonachea` on 2012-09-21 19:54:12
-
Account Deleted ```
I think that means this issue can be closed with NoChange.
I agree. ```
Reported by `brian.wibecan` on 2012-09-21 21:41:20
-
Account Deleted ``` Gary, feel free to re-open if you're not satisfied. ```
Reported by `danbonachea` on 2012-09-21 21:53:22 - Status changed: `NoChange`
-
Account Deleted ``` I agree: NoChange.
```
Reported by `gary.funck` on 2012-09-21 22:00:11
- Log in to comment
Reported by `gary.funck` on 2012-07-17 22:16:18 - Labels added: Type-Clarification, Milestone-Spec-1.3 - Labels removed: Type-Defect