[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
warnin about 'info' is a bug in eigs-base.cc
From: |
Daniel J Sebald |
Subject: |
warnin about 'info' is a bug in eigs-base.cc |
Date: |
Wed, 29 Aug 2012 17:47:51 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.1.16-1.fc14 Thunderbird/3.1.16 |
There are a string of warnings related to 'info' that I noted a couple
posts ago:
In file included from ../../octave/libinterp/dldfcn/eigs.cc:39:0:
../../octave/liboctave/sparse-base-chol.h: In function 'bool
make_cholb(SparseMatrix&, SparseMatrix&, ColumnVector&)':
../../octave/liboctave/sparse-base-chol.h:56:9: warning: 'info' may be
used uninitialized in this function
../../octave/liboctave/eigs-base.cc:368:19: note: 'info' was declared here
[snip]
Those don't have anything to do with "octave.info". 'info' is a
variable here.
First, I assume the following inclusion in eigs.c is intended:
#include "eigs-base.cc"
as I don't see an associated "eigs-base.h" header file. But it is
somewhat unconventional to include C++ code via the header route.
Anyway, these warnings are actually a bug. In the constructor for
sparse_base_chol_rep is variable "info" defined as a reference:
sparse_base_chol_rep (const chol_type& a, octave_idx_type& info,
const bool natural)
: count (1), Lsparse (0), Common (), is_pd (false), minor_p (0),
perms (), cond (0)
{
info = init (a, natural, info);
}
but the init member function definition is not a reference, but passed
in via the stack and is called 'nargout'.
octave_idx_type init (const chol_type& a, bool natural = true,
octave_idx_type nargout = 0);
So nargout = info as an input variable. (info is also used as an output
variable.) I'm not sure what nargout stands for--possibly it is in
reference to the command outputs, i.e., the usual scenario.
I do know there is some conditional code in sparse-base-chol.cc:
if (is_pd || nargout > 1)
{
So this is a bug in the sense that "info", being uninitialized, could be
greater than one (or not) based on what's sitting randomly on the stack.
I believe what is happening is that the sparse code is doing some work
in the background, and if at the point of the conditional test either
the sparse matrix is positive definite (is_pd) or a wrong number of
output arguments was given in the command (nargout), the background
processing will be abandoned.
Judging from the conditional, the number of arguments can be 0 or 1 and
after that there is no further use of nargout. Therefore, I picked a
value of 1 to initialize 'info'. (See patch.)
If there is anyone who thinks there should be some way to determine
'nargout' before issuing the constructor in these two cases (i.e., set
'info' to something other than 1), and this is relevant at this point in
the code (e.g., there isn't already something ahead of it
sanity-checking the number of input and output arguments), please
describe. Right now, nargout seems like something extraneous given it
will never be greater than 1 in the cases I've seen; I'm not 100% sure
though. It can be left as is, so long as something valid is passed into
the constructor.
Dan
octave-sparsechol_info-2012aug29.patch
Description: Text Data
- warnin about 'info' is a bug in eigs-base.cc,
Daniel J Sebald <=