Re: [PATCH 01/10] ivec: introduce the C side of ivec
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 21, 2026, 21:31 UTC
- Message-ID
- <xmqqv7gur6t4.fsf@gitster.g>
- In-Reply-To
- <20260121212024.GC723458@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 17 quoted lines
> On Wed, Jan 21, 2026 at 02:00:15PM -0700, Ezekiel Newren wrote: > >> What about adding clar unit tests to make sure that different ivec >> types have the same size and layout? e.g. sizeof(IVec_c_void) == >> sizeof(IVec_u8); >> sizeof(IVec_c_void) == sizeof(IVec_u16); >> sizeof(IVec_c_void) == sizeof(IVec_u32); >> sizeof(IVec_c_void) == sizeof(IVec_u64); >> ... >> >> As well as other tests for ivec. > > I'm a little hesitant in general to have run-time tests for properties > around undefined behavior, just because the compiler is allowed to do a > lot of tricky things when we get into that territory. Plus it is not > really _solving_ the problem, but perhaps just alerting us slightly > sooner than the production code itself crashing and burning.
Yup, by definition, testing undefined behaviour with code is more or less pointless. Implementation defined behaviour, maybe, but not undefined ones, please.
I thought you already gave them that having different possibilities in a union would work correctly, but perhaps I was reading a different thread? I dunno...