Paolo wrote:
> Is this crap?
I asked for a feature like this before, and I like the feature. But
there are problems with your implementation (as others pointed out).
First to just check for const and noreturn function attribute is asking
for trouble (as you're doing an invalid transformation).
Better invent a __builtin_assert() , or even a __builtin_gcc_assert()
which could have different semantics than C89 assert().
The whole point is to invent something that gcc can safely assume a
condition is true (or false) at the very end of optimization, so the
conditional check can be removed, i.e.
int f(char *x) {
if (__builtin_this_is_false(!(x != NULL)))
abort();
return x ? *x : 0;
}
this may have other uses than a (broken) assert optimization.
Of course, if in this case x _is_ actually NULL, we create wrong code,
but we were asked for this.