The great inapplicable attribute debate

Tomas Lindquist Olsen tomas.l.olsen at gmail.com
Mon Apr 13 10:34:33 PDT 2009


On Mon, Apr 13, 2009 at 3:00 PM, Denis Koroskin <2korden at gmail.com> wrote:
> On Mon, 13 Apr 2009 16:44:25 +0400, Tomas Lindquist Olsen
> <tomas.l.olsen at gmail.com> wrote:
>
>> On Mon, Apr 13, 2009 at 2:05 PM, Frits van Bommel
>> <fvbommel at remwovexcapss.nl> wrote:
>>>
>>> Kagamin wrote:
>>>>
>>>> Stewart Gordon Wrote:
>>>>
>>>>> At the moment, the problem seems to be that the compiler is silently
>>>>> ignoring many cases of (a), (b) and (c) alike.  Some people argue that
>>>>> the
>>>>> spec doesn't forbid such use of inapplicable attributes explicitly, and
>>>>> so
>>>>> the compiler's treatment of these cannot be called a bug.
>>>>>
>>>>> I argue that this isn't right.  Nothing I've managed to find in the
>>>>> spec
>>>>> states or implies that such obviously wrong code is allowed.  So, by
>>>>> applying common sense, one would conclude that it isn't allowed.
>>>>
>>>> Such mood was always in the spec: "AlignAttribute is ignored when
>>>> applied
>>>> to declarations that are not structs or struct members".
>>>
>>> I never saw that before. So it doesn't work for class members? And it
>>> won't
>>> change the alignment of unions if applied to union members (by changing
>>> the
>>> maximum alignment of the members)?
>>>
>>
>> align is defined in terms of the companion C compiler.
>>
>> align(16) int foo; does not guarantee that foo.offsetof is aligned to 16
>> bytes.
>> Since C doesn't have D classes, the align attribute makes little sense
>> here.
>
> You are kind of contradict yourself.
>
> Let's assme that align is defined in terms of the companion C compiler.
> Then, since C doesn't have D classes, the align attribute makes little sense
> when applied to /D classes/.
>
> I don't know how to judge about C built-in types from that.
>
>

Yes now I read it again I can see it doesn't make much sense.

What I meant was just to say that align does not work for classes!!!

What also snuck in there was that align(N) provides no guarantee that
it will actually affect any field offsets. It wasn't supposed to have
anything to do with the discussion, so just ignore it if you will...



More information about the Digitalmars-d mailing list