NetBSD-Bugs archive

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

Re: port-hp300/50852: src/sys/arch/hp300/stand/common/ite.c:239: bad expression



The following reply was made to PR port-hp300/50852; it has been noted by GNATS.

From: Joerg Sonnenberger <joerg%britannica.bec.de@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: port-hp300-maintainer%netbsd.org@localhost, gnats-admin%netbsd.org@localhost,
	netbsd-bugs%netbsd.org@localhost
Subject: Re: port-hp300/50852: src/sys/arch/hp300/stand/common/ite.c:239: bad
 expression
Date: Fri, 26 Feb 2016 13:58:36 +0100

 On Fri, Feb 26, 2016 at 10:55:00AM +0000, dcb314%hotmail.com@localhost wrote:
 > >Description:
 > [src/sys/arch/hp300/stand/common/ite.c:239]: (error) Expression 'whichconsole=++whichconsole%(NITE+1)' depends on order of evaluation of side effects
 > 
 > Source code is
 > 
 >    whichconsole = ++whichconsole % (NITE+1);
 > 
 > Maybe better code
 > 
 >    whichconsole = (whichconsole + 1) % (NITE+1);
 
 Independent of the question of which code is better, I don't think the
 error is correct. The location of the assignment (whichconsole) is not
 changed by the right operand of the =, so the evaluation of the left and
 right operand is invariant under evaluation order of the side effect.
 The side effect of *updating* whichconsole as part of the assignment is
 sequenced *after* the evaluation of the right operand (6.5.16 (3)
 sentence 4. As such, the value here is perfectly well defined according
 to the standard. This is quite different from an expression like
     *(++p) = *(++p); 
 
 Joerg
 


Home | Main Index | Thread Index | Old Index