Ticket #25 (defect)
Opened 1 year ago
Last modified 11 months ago
global_lock_alloc and all_lock_alloc should not use cast from PTS to integer
Status: closed (fixed)
| Reported by: | gary | Assigned to: | somebody |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | component1 | Version: | 1.0 |
| Keywords: | guts | Cc: | |
When compiled with GCC/UPC 4.0.3.4, the global_lock_alloc test fails to compile:
>--------------> Working on unit -- global_lock_alloc COMPILER ERROR: The unit [global_lock_alloc] cannot be compiled The unit will not be run!!! global_lock_alloc.upc: In function 'main': global_lock_alloc.upc:68: error: UPC does not allow casts from shared pointers to integers
Although the GCC/UPC compiler and Berkeley compiler differ in the way that they handle the attempted conversion, the results of such a conversion is not well-defined and the test should use a different method.
If a test needs to access the address field, then it can use upc_addrfield() directly, instead of attempting a cast to integer.
- addrfield[MYTHREAD] = (size_t)lock2; + addrfield[MYTHREAD] = upc_addrfield (lock2);
However, this change in the named tests is likely not enough. As Dan states elsewhere:
"Regarding the specific test, the use of the addrfield array as written is unnecessary ... (even if the integral conversion was permitted and fully implemented, the lack of appropriate integral range implies the truncated value may be non-unique, leading to potential false negatives in the test). It should be replaced with an array of the form:
upc_lock_t * shared all_locks[THREADS];
so that the (upc_lock_t *)'s can be compared directly with no dangerous conversions."
Change History
10/14/07 05:56:14: Modified by apokayi
- status changed from new to closed.
- resolution set to fixed.

test case is changed according to Gary's comment and suggestion.