Skip to contentSkip to conversation

Possible solution for min()/max() war

IDEA+RFC Andy Chou 1 participant 1 message Aug 31, 2001

lore
Share & tools
lore

Andy Chou

author
#0 lore raw

How about:

#define AssertNow(x) switch(1) { case (x): case 0: }

as in:

AssertNow(sizeof(typeof(x)) == sizeof(typeof(y)));

I'm not sure if gcc optimizes this away, but it would be easy for someone to find out.

I didn't invent this.

-Andy

Quoted 5 lines

And I was hoping that somebody could produce some gcc magic replacement for BUG() that means "don't compile me". Perhaps a bit of illegal assembler code with a line reference in? Surely gcc must have something like __builtin_wont_compile()? It just needs to be a leaf of the RTL that evokes a compile error.