[lkml]   [2004]   [Nov]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: sparse segfaults

On Mon, 22 Nov 2004, Mitchell Blank Jr wrote:
> When gcc accepts an arbitrary algebraic expression as an lvalue I'll be
> impressed :-)

Btw, the "+0" thing is something that actually might be dropped pretty
early, and as such a compiler _might_ get it wrong just because it ended
up optimizing the expression away. So you don't need to be all that
impressed, certain trivial expressions might just disappear under some

Side note: the _biggest_ reason why "+0" is hard to optimize away early is
actually type handling, not the expression itself. The C type rules means
that "+0" isn't actually a no-op: it implies type expansion for small
integer types etc.

So I agree that it's unlikely to be a problem in practice, but I literally
think that the reason gcc ends up considering a comma-operator to be an
lvalue, but not a +-operator really _is_ the type-casting issues. A comma
doesn't do implicit type expansion.

What I find really strange is the ternary operator lvalue thing, though. A
ternary operator _does_ do type expansion, so that extended lvalue thing
is really quite complex for ternary ops. Try something like this:

int test(int arg)
char c;
int i;

return (arg ? c : i) = 1023;

and think about what a total disaster that is. Yes, gcc gets it right, but
dammit, what a total crock. The people who thought of this feature should
just be shot.

(Yes, it looks cool. Oh, well. The compiler can always simplify the
expression "(a ? b : c) = d" into "tmp = d ; a ? b = tmp : c = tmp", but
hey, so can the user, so what's the point? Looking at the output from
gcc, it really looks like gcc actually handles it as a special case,
rather than as the generic simplification. Scary. Scary. Scary.)

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2009-11-18 23:46    [W:0.114 / U:0.060 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site