From: Andrew Dunstan on 19 Nov 2009 15:38 Boszormenyi Zoltan wrote: > > Is it *really* a bug? I recalled a comment from my C teacher > in '92 or '93 about this exact issue, that the prefix/postfix > increment/decrement operators are executed in the > statement in an implementation-defined order, > Not if they come after a short-circuit operator such as && - after all, that's what short-circuit evaluation implies. If the left hand operand of && is false the right hand should not be evaluated at all. cheers andrew -- Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
From: Tom Lane on 19 Nov 2009 15:51 Andrew Dunstan <andrew(a)dunslane.net> writes: > Boszormenyi Zoltan wrote: >> Is it *really* a bug? I recalled a comment from my C teacher >> in '92 or '93 about this exact issue, that the prefix/postfix >> increment/decrement operators are executed in the >> statement in an implementation-defined order, > Not if they come after a short-circuit operator such as && - after all, > that's what short-circuit evaluation implies. If the left hand operand > of && is false the right hand should not be evaluated at all. Yes. && is a sequence point and the compiler is not allowed to move side-effects across a sequence point. What your C teacher was warning you against was things like a[i] = i++; '=' is not a sequence point so it's undefined which array index will be stored into. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
From: Boszormenyi Zoltan on 19 Nov 2009 16:00 Tom Lane �rta: > Andrew Dunstan <andrew(a)dunslane.net> writes: > >> Boszormenyi Zoltan wrote: >> >>> Is it *really* a bug? I recalled a comment from my C teacher >>> in '92 or '93 about this exact issue, that the prefix/postfix >>> increment/decrement operators are executed in the >>> statement in an implementation-defined order, >>> > > >> Not if they come after a short-circuit operator such as && - after all, >> that's what short-circuit evaluation implies. If the left hand operand >> of && is false the right hand should not be evaluated at all. >> > > Yes. && is a sequence point and the compiler is not allowed to move > side-effects across a sequence point. What your C teacher was warning > you against was things like > a[i] = i++; > '=' is not a sequence point so it's undefined which array index > will be stored into. > > regards, tom lane > Thanks to both of you, this was really informative. Actually my C teacher didn't mention such optimization barriers. It seems I need to look up the raw C language specs... Best regards, Zolt�n B�sz�rm�nyi -- Bible has answers for everything. Proof: "But let your communication be, Yea, yea; Nay, nay: for whatsoever is more than these cometh of evil." (Matthew 5:37) - basics of digital technology. "May your kingdom come" - superficial description of plate tectonics ---------------------------------- Zolt�n B�sz�rm�nyi Cybertec Sch�nig & Sch�nig GmbH http://www.postgresql.at/ -- Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
First
|
Prev
|
Pages: 1 2 Prev: Oversight in CREATE FUNCTION + EXPLAIN? Next: plruby code and postgres ? |