From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#11082: 24.0.94; u.glyphless member in struct glyph does not fit in 32 bits Date: Sat, 24 Mar 2012 09:01:04 +0200 Message-ID: <83zkb6trdb.fsf@gnu.org> References: Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: dough.gmane.org 1332572533 9271 80.91.229.3 (24 Mar 2012 07:02:13 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 24 Mar 2012 07:02:13 +0000 (UTC) Cc: 11082@debbugs.gnu.org To: YAMAMOTO Mitsuharu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Mar 24 08:02:12 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SBKzL-0002m0-U2 for geb-bug-gnu-emacs@m.gmane.org; Sat, 24 Mar 2012 08:02:12 +0100 Original-Received: from localhost ([::1]:59213 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SBKzL-0006pv-CU for geb-bug-gnu-emacs@m.gmane.org; Sat, 24 Mar 2012 03:02:11 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SBKzI-0006pC-GS for bug-gnu-emacs@gnu.org; Sat, 24 Mar 2012 03:02:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SBKzG-0002nT-7O for bug-gnu-emacs@gnu.org; Sat, 24 Mar 2012 03:02:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57598) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SBKzG-0002nP-3r for bug-gnu-emacs@gnu.org; Sat, 24 Mar 2012 03:02:06 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SBLTB-0005Nw-SY for bug-gnu-emacs@gnu.org; Sat, 24 Mar 2012 03:33:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 24 Mar 2012 07:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11082 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11082-submit@debbugs.gnu.org id=B11082.133257433220635 (code B ref 11082); Sat, 24 Mar 2012 07:33:01 +0000 Original-Received: (at 11082) by debbugs.gnu.org; 24 Mar 2012 07:32:12 +0000 Original-Received: from localhost ([127.0.0.1]:36197 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SBLSN-0005Mi-Aw for submit@debbugs.gnu.org; Sat, 24 Mar 2012 03:32:12 -0400 Original-Received: from mtaout21.012.net.il ([80.179.55.169]:49528) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SBLS7-0005M4-Gw for 11082@debbugs.gnu.org; Sat, 24 Mar 2012 03:32:10 -0400 Original-Received: from conversion-daemon.a-mtaout21.012.net.il by a-mtaout21.012.net.il (HyperSendmail v2007.08) id <0M1D00J00NDFA200@a-mtaout21.012.net.il> for 11082@debbugs.gnu.org; Sat, 24 Mar 2012 09:00:57 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([84.229.241.151]) by a-mtaout21.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0M1D00J8HNHK9030@a-mtaout21.012.net.il>; Sat, 24 Mar 2012 09:00:57 +0200 (IST) In-reply-to: X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:58067 Archived-At: > Date: Sat, 24 Mar 2012 14:23:28 +0900 > From: YAMAMOTO Mitsuharu > > In dispextern.h: > > 316 struct glyph > 317 { > (snip) > 418 /* A union of sub-structures for different glyph types. */ > 419 union > 420 { > (snip) > 447 /* Sub-stretch for type == GLYPHLESS_GLYPH. */ > 448 struct > 449 { > 450 /* Value is an enum of the type glyphless_display_method. */ > 451 unsigned method : 2; > 452 /* 1 iff this glyph is for a character of no font. */ > 453 unsigned for_no_font : 1; > 454 /* Length of acronym or hexadecimal code string (at most 8). */ > 455 unsigned len : 4; > 456 /* Character to display. Actually we need only 22 bits. */ > 457 unsigned ch : 26; > 458 } glyphless; > 459 > 460 /* Used to compare all bit-fields above in one step. */ > 461 unsigned val; > 462 } u; > 463 }; > > The member `u.glyphless' above requires at least 33 bits and does not > fit in the size (32 bits) of `u.val' on many environments. As a > result, equality with respect to the `u.val' member (e.g., used in > GLYPH_EQUAL_P) does not necessarily mean the equality of glyphless > glyphs. ?? Isn't the size of a union defined by its widest member? If so, we just end up wasting some storage here, but we should never truncate a bit field. Do you have an actual test case that shows such kind of a bug? > According to the comment above, it seems to be OK to shorten the > length of `u.glyphless.ch' member from 26 to 25. Could someone > confirm this? Confirmed. From the ELisp manual: To support this multitude of characters and scripts, Emacs closely follows the "Unicode Standard". The Unicode Standard assigns a unique number, called a "codepoint", to each and every character. The range of codepoints defined by Unicode, or the Unicode "codespace", is `0..#x10FFFF' (in hexadecimal notation), inclusive. Emacs extends this range with codepoints in the range `#x110000..#x3FFFFF', which it uses for representing characters that are not unified with Unicode and "raw 8-bit bytes" that cannot be interpreted as characters. Thus, a character codepoint in Emacs is a 22-bit integer number. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I would actually suggest to use 22-bit for this field, to avoid confusion in the future.