On 02/02/2018 03:41 PM, Bruno Haible wrote:
Regarding the parentheses, I disagree: If we put parentheses they should
be like this:
     size_t nplus = (n + sizeof (small_t)) + (2 * sa_alignment_max - 1);
because we want n + sizeof (small_t) consecutive bytes in memory, and the
other summand is for the alignment. Parenthesizing it in the way you suggest
would make the expression_more_  confusing.

Well, it is a matter of style. Personally I find the expression confusing and would find it even more confusing with the extra parentheses. But perhaps that is because I am worried about integer overflow.

we know that INT_MAX >= 2*SIZE_MAX-1 > SIZE_MAX + 100, therefore no 'int'
overflow is possible here.

I was thinking about platforms where SIZE_MAX == INT_MAX, which POSIX and ISO C both allow; on such platforms 'int' overflow is possible. Admittedly platforms with idiosyncrasies like that are rare nowadays. I think Unisys stopped selling their oddball platforms in late 2015.

Reply via email to