From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27412 invoked by alias); 16 Feb 2011 21:37:14 -0000 Received: (qmail 27358 invoked by uid 22791); 16 Feb 2011 21:37:13 -0000 X-SWARE-Spam-Status: No, hits=1.8 required=5.0 tests=AWL,BAYES_00,BOTNET,RCVD_IN_SORBS_DUL,SPF_SOFTFAIL,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from xena.cds1.net (HELO mail.cds1.net) (216.174.197.151) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 16 Feb 2011 21:37:08 +0000 Received: from [192.168.1.100] (unknown [192.82.28.137]) by mail.cds1.net (Postfix) with ESMTP id 13F84E000524; Wed, 16 Feb 2011 13:37:05 -0800 (PST) Message-ID: <4D5C437F.5080207@cds1.net> Date: Wed, 16 Feb 2011 21:49:00 -0000 From: Bob Plantz User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 MIME-Version: 1.0 To: Jason Mancini CC: jwakely.gcc@gmail.com, gcc-help@gcc.gnu.org Subject: Re: infinite for-loop and related question References: , In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-02/txt/msg00244.txt.bz2 On 02/16/2011 12:41 PM, Jason Mancini wrote: > Though I still find the output of this odd: > > for (char i(1); i>0; ++i) > printf("%d %d\n", i, sizeof(i)); > > ... > 362195 1 > 362196 1 > 362197 1 > ... > > For very large values of char! ^_^ > > Jason That's odd. With g++ 4.4.5 on an x86-64 machine in 64-bit mode I get: --- 125 1 126 1 127 1 which is what I would expect. That is, i is a (signed) char, and when it goes over 127 it becomes a negative number, so the loop terminates. --Bob