Boost logo

Ublas :

From: Peter Schmitteckert (peter_at_[hidden])
Date: 2005-08-19 07:36:56


On Fri, 19 Aug 2005, Gunter Winkler wrote:

> ALLOC::size_type, T, bool) [with T = int, ALLOC =
> boost/numeric/ublas/storage.hpp:110: Warnung: `int*data'
> might be used uninitialized in this function
> We should change line 110
> pointer data = 0;
> otherwise data_ will have random content if the new size is zero.
> (Alternatively we can add an else clause to "if (size) { ... }" )

If it's never referenced is not a Problem.
Never being referenced means not before an initialization.

BTW, we should use
  pointer data = NULL;

I'd like to remark, that pointer may not have random content,
but it's use it undefined.

e.g. a code like

double a;
double b;


std::cout << b << std::endl;

is undefined and can (and will on some compilers with -O3)
lead to crashes somewhere else in the code.

Best wishes,


Dr. Peter Schmitteckert
TKM / CFN University of Karlsruhe
++49 721 608 3363