From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9159 invoked by alias); 16 Nov 2005 11:08:00 -0000 Received: (qmail 9120 invoked by uid 22791); 16 Nov 2005 11:07:55 -0000 Received: from mail1.domainserver.de (HELO smtp.domainserver.de) (213.83.41.134) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Wed, 16 Nov 2005 11:07:55 +0000 Received: from [213.183.84.169] (helo=mobotix.com) by smtp.domainserver.de with esmtp (Exim 3.36 #1) id 1EcL8c-0002LA-00; Wed, 16 Nov 2005 12:07:38 +0100 Received: from [192.168.1.120] (HELO danielx.mobotix.net) by mobotix.com (CommuniGate Pro SMTP 4.2.10) with ESMTP id 2432471; Wed, 16 Nov 2005 12:07:36 +0100 From: Daniel Kabs To: Ryan Mansfield Subject: Re: gcc not warning on all occurences of operations with undefine d results? Date: Wed, 16 Nov 2005 11:08:00 -0000 User-Agent: KMail/1.7.2 Cc: 'Ladislav Mecir' , gcc-help@gcc.gnu.org References: <3518719F06577C4F85DA618E3C37AB9101389220@nimbus.ott.qnx.com> In-Reply-To: <3518719F06577C4F85DA618E3C37AB9101389220@nimbus.ott.qnx.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200511161207.36464.daniel.kabs@gmx.de> Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2005-11/txt/msg00241.txt.bz2 Hello! On Wednesday 16 November 2005 00:26, Ryan Mansfield wrote: >>> ... if I have an >>> expression and somewhere in that expression, I use an increment >>> (decrement) operator on a variable, I can not mention that variable >>> elsewhere in the expression. >> >> I think, that this is wrong. The exact rule should be more like "...if >> the result of the operation is not defined by standard..." > > The exact rule is in section 5.1.2.3 Paragraph 2 I just wanted to give a "rule of thumb". To help fellow programmers to avoid that trap. Granted, my "rule of thumb" is not 100% correct but if you adhere to it, you avoid most of the problematic uses of ++ and --. And it's easy to remember. :-) I think, a lot easier than what I found here: http://c0x.coding-guidelines.com/6.5.html | Between the previous and next sequence point an object shall have its stored | value modified at most once by the evaluation of an expression. | Furthermore, the prior value shall be read only to determine the value to be | stored. | Except as specified later, the order of evaluation of subexpressions and the | order in which side effects take place are both unspecified. What about rephrasing the "rule" as: "If I have an assignment and somewhere in that assignment, I use an increment (decrement) operator on a variable, I should not mention that variable elsewhere in the assignment". Cheers Daniel