This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: What should alignof do with incomplete types?


Jamie Lokier wrote:

> IMO an error is appropriate, just as for sizeof.  Does Apple have code
> which depends on this being a just warning?

It appears not.  I did a little digging in Apple's bug database, and the
problem was originally reported within NeXT in 1992(!).  No code depending
on any particular behavior, it was just an observation that __alignof__
ought to warn about incomplete types, just as sizeof did at the time.
Quoting from the report: "Stallman does not consider this a bug and does
not plan to fix it".  So then somebody at Apple added the warning locally.

The ironic part is that nowadays, sizeof on an incomplete type generates
an error!  So I think it makes the most sense for __alignof__ to also
generate an error when used on incomplete types.

Stan

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]