This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Joseph Myers wrote:
We can assume that PTRDIFF_MAX == SIZE_MAX / 2 (and that ptrdiff_t, size_t and pointers have the same power-of-2 width, which is at least 32).
OK, then we needn't bother with the static assertion. Is there a good place to document assumptions like this one, in the glibc manual I suppose?
Using verify.h in any glibc code not coming from gnulib would be odd; just use _Static_assert.
Although the point is now moot for this patch, I prefer the readability of 'verify'. Compare this:
verify (PTRDIFF_MAX <= SIZE_MAX / 2); to this: _Static_assert (PTRDIFF_MAX <= SIZE_MAX / 2, "PTRDIFF_MAX is not more than half of SIZE_MAX");With just one static assertion it's no big deal, but Gnulib has files with dozens and the readability savings add up.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |