Messages in this thread | | | Date | Mon, 22 Nov 2004 10:54:17 -0800 (PST) | From | Linus Torvalds <> | Subject | Re: sparse segfaults |
| |
On Mon, 22 Nov 2004, Mitchell Blank Jr wrote: > > When I want to do that I just use: > > #define MAX_SOMETHING (max_of_something + 0)
Yes, I think I've done that too, and that works. My point is that the silly comma-expression should _also_ work, and I don't see any _valid_ use of the comma-expression as an lvalue.
I suspect (but don't have any real argument to back that up) is that the gcc "extended lvalues" fell out as a side effect from how gcc ended up doing some random semantic tree parsing, and it wasn't really "designed" per se, as much as just a random implementation detail. Then somebody noticed it, and said "cool" and documented it.
That's actually in my opinion a really good way to occasionally find a more generic form of something - the act of noticing that an algorithm just happens to give unintentional side effects that can actually be mis-used. So I don't think that it's a bad way per se to add features, especially as they then are often free (or even "negative cost", since _not_ adding the feature would entail having to add a check against it).
And for all I know, many of the _good_ gcc features ended up being done that way too.
But I think the (unintentional) downsides of these features are bigger than the advantages.
Linus - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |