clangupc / clang-upc

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

Negative blocksize permitted w/ -fupc-sptr=struct #46

Closed PHHargrove closed 10 years ago

PHHargrove commented 10 years ago

This is the first "child" issue of upc2c issue #74.

When one passes -fupc-pts=struct to clang-upc, the value of UPC_MAX_BLOCK_SIZE is correctly set to 4294967295 (aka 2^32-1 or 0xFFFFFFFF). The problem I am seeing is with the following, based on the test guts_main/blocksize_neg.upc:

    shared [-3] int *p;

This code is accepted by clang-upc! Use of clang-upc2c renders -3 as as its 32-bit twos-complement equivalent 0xFFFFFFFD. So, I assume that clang-upc has accepted the blocksize of -3 after checking 0xFFFFFFFD <= 0xFFFFFFFF. This is consistent with the behavior with the default packed pts rep:

f.upc:1:9: error: block size 4294967293 exceeds UPC_MAX_BLOCK_SIZE
shared [-3] int *p;
        ^~
1 error generated.

It would appear that some additional logic is needed to protect against negative block size in the pts=struct case, which the pts=packed is detecting for the wrong reason. The additional check would/could also improve the error message for the pts=packed case.

RFE: while somebody is looking at this, I think it would be helpful to the end-user to include the value of UPC_MAX_BLOCK_SIZE in the error message for block-size-too-large.

PHHargrove commented 10 years ago

Would it be acceptable to cap the supported UPC_MAX_BLOCK_SIZE at 0x7FFFFFFF (by limiting UPCPhaseBits to at most 31)? If so, then this issue resolves almost trivially.

PHHargrove commented 10 years ago

fix confirmed. thanks.