Patch: __alignof__(void) -> most strict alignment

Mark Mitchell
Fri Sep 25 08:34:00 GMT 1998

Nathan --

>>>>> "Nathan" == Nathan Sidwell <> writes:

    Nathan> This is a multi-part message in MIME format.

    Nathan> --------------782A4D632DBA Content-Type: text/plain;
    Nathan> charset=us-ascii Content-Transfer-Encoding: 7bit

    Nathan> hi, This patch changes the (currently unspecified)
    Nathan> behaviour of the gcc extension __alignof__(void). It
    Nathan> currently returns 1, this changes it to return the value
    Nathan> BIGGEST_ALIGNMENT / BITS_PER_UNIT, i.e. the most strict
    Nathan> alignment required on the target. Such a value is needed
    Nathan> in, for instance, memory allocators.

Personally, I'm not big on this extension; I'd be much happier if
alignof and sizeof void were errors as one would expect with standard
C/C++.  (void is an incomplete type.)  The information you require
could be made as a builtin function, and I think this would be a
cleaner approach.  But, as you mentioned, we've all argued this
before, so I suppose it's now in the hands of our esteemed

That aside, I think your patch should contain patches to the
documentation; if we're going to provide an extension to GCC we should
at least make sure it's a well-defined and documented one!  (Yes, I
know that alignof is already a GCC extension, but the behavior you are
suggesting is not intuitive, to me, given the name `alignof', so I
think of this as an extension-to-an-extension...)

Mark Mitchell
Mark Mitchell Consulting

More information about the Gcc-patches mailing list