Boost logo

Ublas :

Subject: Re: [ublas] A few patches for bugs and a feature
From: Jesse Perla (jesseperla_at_[hidden])
Date: 2010-07-16 08:58:50


David Bellot <david.bellot <at> gmail.com> writes:
> I'm glad with bugs with MSVC because I don't use windows at all so I couldn't find those.

I think the only one of these patches that could cause regressions is
the change for size 0 vector on MSVC. The error message from MSVC
suggests that this zero size arrays is nonstandard and that this could
be a problem on other compilers (though not on GCC/Intel that I
tested):

Compiling a bounded_vector<double, 0>:

The first warning is:
 warning C4200: nonstandard extension used : zero-sized array in struct/union
1> Cannot generate copy-ctor or copy-assignment operator when
UDT contains a zero-sized array

Then the error is:
1>C:\working\sandbox\boost_trunk\boost/numeric/ublas/vector.hpp(805):
error C2503: 'boost::numeric::ublas::vector<T,A>' : base classes
cannot contain zero-sized arrays

My fix was just to change the underlying storage size inside of storage.hpp

BOOST_UBLAS_BOUNDED_ARRAY_ALIGN value_type data_ [(N>0)?N:1];
instead of
BOOST_UBLAS_BOUNDED_ARRAY_ALIGN value_type data_ [N];

But this changes the size of the underlying object in a shady way. If
any code is doing tricks for storing them (like serializatiion?) it
could break things.

Perhaps conditionally using a different type if N=0 (like a static
value_type* set to NULL?) would be a better approach, but that is all
getting above my paygrade.

Thanks,
Jesse