X-Spam-Check-By: sourceware.org Message-ID: <43DD50A4.5446A7FE@dessent.net> Date: Sun, 29 Jan 2006 15:32:52 -0800 From: Brian Dessent MIME-Version: 1.0 To: cygwin@cygwin.com Subject: Re: bizarre g++ behavior after reinstalling cygwin References: Content-Type: text/plain; charset=iso-8859-1 X-IsSubscribed: yes Reply-To: cygwin@cygwin.com Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Delivered-To: mailing list cygwin@cygwin.com Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id k0TNX7JP026279 Vadim Oganesyan wrote: > Digging in I found that none of the "i=i++" calls inside for-loops work. I Please get a book on C and then read it. "i=i++" is undefined behavior according to the standard, and upon seeing this the compiler is allowed to do anything it wants -- it could generate code to format your hard drive if it wanted to. That your program even worked at any point with any compiler is pure luck. The reason it is undefined is because it attempts to modify 'i' in two places (through the assignment and through ths side effect of ++-postincrement) in the same sequence point. This is undefined according to §6.5.2. But that aside, the expression "i=i++" is just nonsense. If you want to increment i, all you need is "i++", or if you're feeling verbose "i = i + 1" or "i += 1". But "i=i++" is invalid, and should not be used in any C program. See also: Brian -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/