From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Lars J. Aas" Newsgroups: gmane.lisp.guile.devel Subject: Re: SCM_POSFIXABLE(-1) fails with MSVC++ 6.0 Date: Sun, 25 Aug 2002 15:27:27 +0200 Sender: guile-devel-admin@gnu.org Message-ID: <20020825132727.GB22670@sim.no> References: <20020823104054.GA27923@sim.no> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1030282080 20876 127.0.0.1 (25 Aug 2002 13:28:00 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 25 Aug 2002 13:28:00 +0000 (UTC) Cc: Guile Devel Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17ixQs-0005Qb-00 for ; Sun, 25 Aug 2002 15:27:58 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17ixS5-0002c7-00; Sun, 25 Aug 2002 09:29:13 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17ixRZ-0002X6-00 for guile-devel@gnu.org; Sun, 25 Aug 2002 09:28:41 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17ixRX-0002Wt-00 for guile-devel@gnu.org; Sun, 25 Aug 2002 09:28:40 -0400 Original-Received: from trh.sim.no ([213.236.166.75] helo=sim.no) by monty-python.gnu.org with smtp (Exim 4.10) id 17ixRW-0002WG-00 for guile-devel@gnu.org; Sun, 25 Aug 2002 09:28:38 -0400 Original-Received: (qmail 22870 invoked by uid 2000); 25 Aug 2002 13:27:27 -0000 Original-To: Dirk Herrmann Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.24i Errors-To: guile-devel-admin@gnu.org X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.lisp.guile.devel:1149 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:1149 Dirk Herrmann wrote: : On Fri, 23 Aug 2002, Lars J. Aas wrote: : : > Lars J. Aas wrote: : > : Changing the alternative definition of SCM_LONG_BITS to cast the value : > : to long like this works... : > : : > : # define SCM_LONG_BIT ((long)(SCM_CHAR_BIT * sizeof (long) / sizeof (char))) : > : > Come to think of it, the cast is better placed on the inside so it's more : > evident what is being done (stopping the unsigned-ness of the sizeof()- : > operations to propagate incorrectly out through the macro invokation) so : > it's not removed later by someone not knowing about this compiler bug. : > : > # define SCM_LONG_BIT (SCM_CHAR_BIT * ((long) (sizeof (long) / sizeof (char)))) : > : > or s/long/int/ on the cast? : > : > BTW, is anyone reading these mails? ;) : > : > Lars J : : I am not sure I understand the problem here: is the failure of testing : -1 <= sizeof(long) a compiler bug, or is the strange behaviour defined : in the C language? I haven't studied the C specification under a microscope, but it has got to be a compiler bug. What I guess is happening is that sizeof() is defined to return an unsigned value, and consequently -1 is interpreted as an unsigned value. Exactly how data type qualifiers are supposed to propagate over unary tests isn't something I know for sure, but gcc handles it as one would expect. BTW, I don't think the define makes sense at all. I believe it's part of the C standard that sizeof(char) should always return 1, whether the char type is the size of a byte or not. Besides, if it had returned the number of bytes a char is - why would one want to divide by it? Multiply perhaps, but that would only be if sizeof(long) returned the number of _chars_ in a long, and sizeof(char) returned the number of _bytes_ in a char, which wouldn't make sense either. So there's some stuff I think is wrong there, but I guess that part of the #if/else isn't that often used, and when it's used, it doesn't affect the result since it's a divide-by-one thing and char is always a byte long. I propose that the define is changed to: # define SCM_LONG_BIT (SCM_CHAR_BIT * ((int) sizeof(long))) Lars J _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel