Subject: standards/9333: sizeof(char) is 1, period, by definition, always.
To: None <gnats-bugs@gnats.netbsd.org>
From: Seebs <seebs@lobe.fleet.plethora.net>
List: netbsd-bugs
Date: 02/02/2000 10:53:20
>Number:         9333
>Category:       standards
>Synopsis:       ctype.h uses "sizeof(char)<<3" when it means "CHAR_BIT".
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    standards-manager (NetBSD Standards Conformance bug manager)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Feb  2 10:51:00 2000
>Last-Modified:
>Originator:     Seebs
>Organization:
	No.
>Release:        -current, 2/2/02
>Environment:
System: NetBSD lobe.fleet.plethora.net 1.4Q NetBSD 1.4Q (LOBE) #3: Fri Jan 28 11:26:00 CST 2000 seebs@lobe.fleet.plethora.net:/usr/src/sys/arch/i386/compile/LOBE i386

>Description:
	ctype.h says "sizeof(char)<<3".

	This is "8".  sizeof(char) is 1.  Period.  sizeof() yields results
	using 'char' *as the unit*.

	It doesn't matter how many bits char has, sizeof(char) is 1.

>How-To-Repeat:
	Skim headers.

>Fix:
	Use CHAR_BIT, if you want "# of bits in a char".  This is always
	correct, and looks a little less silly.

*** ctype.h.orig	Wed Feb  2 12:44:16 2000
--- ctype.h	Wed Feb  2 12:45:37 2000
***************
*** 120,126 ****
  #endif
  
  #ifdef _CTYPE_PRIVATE
! #define _CTYPE_NUM_CHARS	(1<<(sizeof(char)<<3))
  
  #define _CTYPE_ID	 	"BSDCTYPE"
  #define _CTYPE_REV		2
--- 120,126 ----
  #endif
  
  #ifdef _CTYPE_PRIVATE
! #define _CTYPE_NUM_CHARS	(1<<CHAR_BIT)
  
  #define _CTYPE_ID	 	"BSDCTYPE"
  #define _CTYPE_REV		2
>Audit-Trail:
>Unformatted: