Topic: adding alignment support n2140 & n2165 inconsistent alignment value calculation


Author: newsnarad@delphin.all.de (daran)
Date: Mon, 5 Nov 2007 17:59:55 GMT
Raw View
In article <4645ffce$0$4052$bbae4d71@news.suddenlink.net>,
 cppljevans@suddenlink.net (Larry Evans) wrote:

> On 05/10/2007 05:57 PM, jg wrote:
> [snip]
> > In practice, is there any alignment that is not 2's power ?
>
> If boost::alignment_of is correct, then apparently so:
>
> http://archives.free.net.ph/message/20051026.011808.725ad7bb.en.html

Not necessarily. boost::alignment_of only guarantees to return a (small)
integral multiple of the needed alignment. In the linked case it
returned 12 where the needed alignment was 4.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: Larry <cppljevans@suddenlink.net>
Date: Mon, 7 May 2007 21:12:57 CST
Raw View
===================================== MODERATOR'S COMMENT:
 Apologies for the delay in moderation; this appears to be caused
by my ISP (Cox) dropping and/or blocking e-mail.


===================================== END OF MODERATOR'S COMMENT
Sorry if the following appears more than once.  I sent it but
got no response in 24 hrs; so, I'm resubmitting.
--- original message: ---

According to the table on:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/#mailing2007-03

the document:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2140.pdf

is the predecessor to the document:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2165.pdf

According to n2165, page. 10, aligned_storage::alignment_value is:

  the least common multiple of all Alignments

However, according to n2140, page 5, aligned_storage::alignment_value
is the "largest digit that is set" in "the binary-ors all Alignments".

I can understand n2165; however, I don't understand n2140.  The
largest bit set is a number from 0 to 31 on a 32 bit machine.  So, if
the only element in an aligned_union is an int, with alignment 4, then
the largest digit set of binary-or of 4 is 2, and 2 is the wrong
alignment for an int.  OTOH, if n2140 meant 2 raised to the power of
the largest digit that is set, then it would make more sense, but
this, AFAICT, would not be the same as the least common multiple.  So,
is n2140 wrong?  In addition, if all alignments are 2 raised to some
unsigned power (as required by paragraph 4 on page 5 of n2140) then
wouldn't the max of all alignments give the correct alignment for the
union?  OTOH, if the extended alignments (page 3 of n2165) were
allowed, then least common multiple instead of max would be the
correct method for calculating the composite (union) alignment.  So,
is lcm instead of max used on page 10 to accommodate extended
alignments?

TIA.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: jg <jgu222@gmail.com>
Date: Thu, 10 May 2007 16:57:57 CST
Raw View
===================================== MODERATOR'S COMMENT:



===================================== END OF MODERATOR'S COMMENT
On May 7, 8:12 pm, Larry <cppljev...@suddenlink.net> wrote:
> ===================================== MODERATOR'S COMMENT:
>  Apologies for the delay in moderation; this appears to be caused
> by my ISP (Cox) dropping and/or blocking e-mail.
>
> ===================================== END OF MODERATOR'S COMMENT
> Sorry if the following appears more than once.  I sent it but
> got no response in 24 hrs; so, I'm resubmitting.
> --- original message: ---
>
> According to the table on:
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/#mailing2007-03
>
> the document:
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2140.pdf
>
> is the predecessor to the document:
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2165.pdf
>
> According to n2165, page. 10, aligned_storage::alignment_value is:
>
>   the least common multiple of all Alignments
>
> However, according to n2140, page 5, aligned_storage::alignment_value
> is the "largest digit that is set" in "the binary-ors all Alignments".
>
> I can understand n2165; however, I don't understand n2140.  The
> largest bit set is a number from 0 to 31 on a 32 bit machine.  So, if
> the only element in an aligned_union is an int, with alignment 4, then
> the largest digit set of binary-or of 4 is 2, and 2 is the wrong
> alignment for an int.  OTOH, if n2140 meant 2 raised to the power of
> the largest digit that is set, then it would make more sense, but
> this, AFAICT, would not be the same as the least common multiple.  So,

I didn't read the document, instead of answering your question, I am
just saying mine.

If all the alignment is 2's power,  I think the lcm is the same as
largest digit
that is set" in "the binary-ors all Alignments". (assume n2140 means
2's power.)

In practice, is there any alignment that is not 2's power ?

JG

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]