On 10/12/2012 02:47 PM, Kinkie wrote:
> On Fri, Oct 12, 2012 at 7:37 PM, Alex Rousskov
> <rousskov_at_measurement-factory.com> wrote:
>> On 08/01/2012 01:13 PM, Kinkie wrote:
>>
>>> the attached patch partly fixes CLANG support for Trunk.
>>
>>> - Slot slots[]; ///< slots storage
>>> + Slot *slots; ///< slots storage
>> ...
>>> + slots=new Slot[limit];
> This clang issue is with non-POD dynarrays.
> Which can be solved in three ways, in my opinion: waiting for clang to
> implement this feature, not using dynarrays, or using POD. While I
> agree that reverting would be a good option to have something that
> works immediately, may I suggest to try and use a POD dynarray +
> typecasts to shuffle data in and out? It's a hack, but it should carry
> us through until clang catches up.
It is not that easy because some of the array elements have atomic locks
and other complex objects in them. Their constructors matter. Dumbing
them down to PODs will create problems elsewhere.
I have educated myself a little on this issue. It looks like slots[]
arrays are called "flexible arrays". They first appeared in C99
standard, after C++ was standardized in 1998. Technically, they are
currently illegal in C++ (PODs or not).
The recommended portable way is, apparently, to declare an array of size
one (i.e., slots[1] instead of slots[]) and then allocate the actual
elements as needed. This is not ideal for our purposes, unfortunately,
because that single element gets allocated twice: first during parent
object construction and then when we allocate the array using placement-new.
I am currently investigating whether we can simply ignore
double-allocation or have to work around it by making the placement-new
call smarter.
Cheers,
Alex.
Received on Fri Oct 12 2012 - 22:14:32 MDT
This archive was generated by hypermail 2.2.0 : Sat Oct 13 2012 - 12:00:12 MDT