emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] trunk r114450: * dispnew.c (clear_glyph_row, copy_row_


From: Paul Eggert
Subject: Re: [Emacs-diffs] trunk r114450: * dispnew.c (clear_glyph_row, copy_row_except_pointers):
Date: Tue, 24 Sep 2013 08:45:18 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0

Dmitry Antipov wrote:
> portable code should not 1) assume
> that sizeof (int) == sizeof (size_t) and 2) assume that
> offsetof (type, member) is always less than INT_MAX, isn't it?

Well, the usual style elsewhere in Emacs is to use enums
for offsetof-related constants, so I did that in trunk bzr 114453.
This has the minor technical advantage of requiring a compiler
diagnostic (as opposed to relying on undefined behavior) if
the offsetof value exceeded INT_MAX.  I suppose that might happen
due to compiler misconfiguration; it should never happen in any
remotely-plausible computer, but it doesn't hurt to check.

As for alignment, I once dealt with a real Unix machine that
had 3-byte words that were always aligned on 4-byte boundaries.
Adding 1 to a char * value added 1 to its internal representation
two times out of three; the other time, it added 2, to skip over
the byte that wasn't there.  Admittedly this was a while ago,
but it did teach me to mistrust assumptions about alignment.
In this case the unportable assumption cluttered up the code
and led to confusion about what the code really was assuming,
and it wasn't worth adding the complexity to the assertion to
make it state clearly what the assumption was, so I thought
it simpler to remove it.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]