Laszlo Ersek <ler...@redhat.com> writes: > On 11/04/15 17:35, Gabriel L. Somlo wrote: [...] >> + assert(size > 0 && size <= sizeof(value)); > > It's a matter of taste, and I won't insist at all, just mention that I > didn't write those two assert()s as separate statements :) > > Namely, with a conjunction (P1 && P2 && ... && Pn), you have the > possibility to spell the assertion as: > > assert(P1); > assert(P2); > ... > assert(Pn); > > And, if any one of those fails, you will know *which one*. Because the > line number in the "assertion failed" message will tell you.
Yes, matter of taste, but that can't stop me having opinions on matters of taste ;) You pay for the more detailed assertion failure reporting with extra source code clutter (as written, it's immediately obvious that it's a bounds check, less so if split), and extra object code when NDEBUG is off (which it should always be). Personally, I'm content to fish details out of a core dump. YMMV. [...]