Ticket #6 (defect)
Opened 1 year ago
Last modified 1 year ago
blocksizeof2_neg incorrectly checks for size_t return value.
Status: closed (fixed)
| Reported by: | gary | Assigned to: | apokayi |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | component1 | Version: | |
| Keywords: | guts | Cc: | |
When compiled with GCC/UPC 4.0.3.4, blocksizeof2_neg fails as follows:
--------------> Working on unit -- blocksizeof2_neg\n ERROR: The NEGATIVE unit [blocksizeof2_neg] pass the compilation phase The unit will not be run!!! TEST FAILED for the unit [blocksizeof2_neg]
The body of the test reads as follows:
/*
* To check that the type of the result from upc_blocksizeof operator is size_t
*/
/*
* upc_blocksizeof function returns size_t type but array_block_size was defined as long type
* So compiler MUST raise an ERROR accordingly
*/
long array_block_size;
array_block_size = upc_blocksizeof(A);
On some architectures, "long" is compatible with size_t, and therefore this test passes. The test needs to be fixed/improved, but I'm unsure how to build a negative test for this case.
Change History
09/06/07 16:39:20: Modified by sbahra
- owner changed from somebody to apokayi.
- summary changed from blocksizeof2_neg incorrectly checks for size_t return value? to blocksizeof2_neg incorrectly checks for size_t return value..
09/07/07 11:54:01: Modified by kunxi
09/24/07 16:07:03: Modified by apokayi
- status changed from new to closed.
- resolution set to fixed.
test case is dropped

If two variables have the same length, and they are assignable, we can assume they share the same type, or at least "duck type". so the test would be:
size_t array_block_size; // if it compiles, return value of upc_blocksize is assignable to size_t. array_block_size = upc_blocksizeof(A); // if it can be assigned to size_t variable, it is size_t. if (sizeof(array_block_size) != sizeof(size_t)) { GULA_FAIL("upc_blocksizeof() failed return correct type --> size_t"); }And move this unit test to UNITS from UNITS_NEG in guts_main.sh