[mpich-discuss] robust-ifying MPI_File_seek and negative offsets

Dave Goodell goodell at mcs.anl.gov
Fri Apr 13 14:29:57 CDT 2012


On Apr 13, 2012, at 7:58 AM CDT, Jed Brown wrote:

> unary - is applied to an unsigned type, producing an unsigned result. The actual value is implementation defined, but most/all compilers on twos complement systems will insert a normal signed negation instruction (NEG on Intel).

I don't disagree with most of your analysis, but isn't the unsigned result well defined by other parts of the standard?  Doesn't it have to be done in terms of modulo arithmetic (irrespective of whether 2's complement, 1's complement, or sign and magnitude representations are used)?  So the resulting unsigned value of "-(size_t)4" has to be "SIZE_MAX+1-4", right?

Relevant C/C++ standards sections and similar rationale here: http://stackoverflow.com/a/1269049/158513

-Dave



More information about the mpich-discuss mailing list