On Thu, Mar 13, 2025 at 6:20 PM Junio C Hamano <gitster@xxxxxxxxx> wrote: > > "brian m. carlson" <sandals@xxxxxxxxxxxxxxxxxxxx> writes: > > >> Is this something we can use in our project? I am just double > >> checking. > > > > I believe it's valid in C99. Certainly some compiler might be bad at > > optimizing, or a user may have compiled with -O0, but this is run in CI, > > where we have known good compilers and can control the optimization > > flags. I doubt GCC, Clang, or MSVC will have problems here, and since > > this is not on by default, users using something less capable (the Tiny > > C Compiler, maybe?) or a vendor compiler won't even see it. > > > > Was there some other case that you were concerned about? > > Licensing, mostly, as clever things we see are not necessarily home > grown. I know the patch came with DCO sign-off, but it does not > hurt to double check. These two lines: > +extern int not_supposed_to_survive; > +#define assert(expr) ((void)(not_supposed_to_survive || (expr))) , which serve as the core trick, I had used elsewhere before. Doing some searches, it looks like those likely came from https://stackoverflow.com/questions/10593492/catching-assert-with-side-effects. And it appears that StackOverflow is CC-BY-SA-3.0 or -4.0. Doh, sorry. Anyone got a clever alternative? The rest of the patch was all written by me.