Re: fun with ?:

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Al Viro wrote:-

> > Sparse constant folding here?  If so, and if you really think this case
> > matters, let's have an option to turn on this constant folding, and warn
> > whenever we see it.
> 
> Usual sparse constant folding is _almost_ OK, provided that we play a bit
> with evaluate_expression() and let it decide if subexpression is an integer
> constant expression.  No prototype changes, we just get a global flag
> and save/restore it around sizeof argument handling and several other
> places.  It's actually pretty easy.  And if we get "it is an integer
> constant expression", well, then caller can call expand stuff.
> 
> "Almost" bit above refers to another bit of insanity, fortunately easily
> handled; we need division by zero to raise no error and just yield "the
> entire thing is not an integer constant expression with value 0".  That's
> exactly what longjmp() is for...

I respect you too much Al to doubt you, but I do warn you that
getting the rules for integer constant expressions right in C is
harder than it looks.  GCC is not very close.  The immediate
cast of float bit painful in recursive descent parsers.  I've managed
to find cases where Comeau's online compiler doesn't get it right,
and they're pretty good.

I have a test suite that tests these things to an unhealthy level of
pedantry for my own implementation (the only one I know passes the lot,
of course 8-); happy to run sparse when you've finished if you like.

Neil.
-
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux