Am 13.08.2016 um 11:09 schrieb Jeff King:
On Sat, Aug 13, 2016 at 11:01:21AM +0200, René Scharfe wrote:
This section is about "The FLEXPTR_* variants", so use FLEXPTR_ALLOC_STR
in the example.
Oops, yeah. Your patch is clearly an improvement.
Since this is obviously an easy mistake to make (using one form rather
than the other), I wondered if the compiler would catch it.
I think it would catch an accidental use of FLEXPTR instead of FLEX,
because it involves an attempted assignment of an array. But I don't
think we would catch the reverse; we'd just write the data directly on
top of the pointer. That would probably crash immediately at runtime, so
if you exercise the code at all in tests, it is OK. But something to be
I suppose it could assert(sizeof((x)->flexname) == FLEX_ALLOC) or
something, but I'm not sure if it is worth worrying about.
A compilation error or warning would be nice. I scratched my head quite
a bit before figuring out that the example was wrong. Copy&paste from a
reputable source must be correct, right? :)
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html