From help-request at octave dot org Mon Nov 14 05:24:46 2005 Subject: Re: Octave chokes on this in some systems From: Shai Ayal To: "John W. Eaton" CC: Quentin Spencer , help@octave.org Date: Mon, 14 Nov 2005 13:16:26 +0200 I applied this patch manually (i.e. copied the function body from cc to h) in 2.1.72 and compiled on my chocolate FC4 with gcc-4 & gfortran (linking with atlas-custom from Quentin). IT WORKS it passes make test and runs the "test_caller/test_callee" function John W. Eaton wrote: > On 13-Nov-2005, Quentin Spencer wrote: > > | Shai Ayal wrote: > | > | > Just to add to the general confusion it runs well on my NOT vanilla > | > (shall we say chocolate?) FC4 with octave 2.1.71 where all octave > | > stuff is compiled using gcc-3.2.3: > | > > | > `mkoctfile -p CXX` -v > | > Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs > | > Configured with: ../configure --prefix=/usr --mandir=/usr/share/man > | > --infodir=/usr/share/info --enable-shared --enable-threads=posix > | > --disable-checking --with-system-zlib --enable-__cxa_atexit > | > --enable-languages=c,c++,f77 --disable-libgcj --host=i386-redhat-linux > | > Thread model: posix > | > gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-47.fc4) > | > | > | Actually, I think this helps clear up the confusion. We seem to have a > | pattern here: it breaks with gcc 4 and it works with gcc 3. > > The following change to Octave will allow the test_caller/test_callee > functions to work with GCC 4.0.2, at least on my system (Debian x86 > testing, everything compiled with GCC 4.0.2). But since the only > change to Octave is to move the function definition from a .cc file to > a .h file, this does seem to indicate a bug of some sort in GCC or > libstdc++ (octave_value_list is implemented using a std::vector > object). > > The crash was happening in the octave_value_list destructor. Maybe > the problem is similar to this one: > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24196 > > ? > > The diff is relative to the current CVS. To apply it to older > sources, change octave_idx_type to int. Or, just make the same change > by hand (move the definition of the resize function from oct-obj.cc to > oct-obj.h). > > jwe > > > Index: src/oct-obj.cc > =================================================================== > RCS file: /cvs/octave/src/oct-obj.cc,v > retrieving revision 1.33 > diff -u -r1.33 oct-obj.cc > --- src/oct-obj.cc 26 Apr 2005 19:24:33 -0000 1.33 > +++ src/oct-obj.cc 14 Nov 2005 04:43:09 -0000 > at @ -43,22 +43,6 @@ > return true; > } > > -void > -octave_value_list::resize (octave_idx_type n, const octave_value& val) > -{ > - octave_idx_type len = length (); > - > - if (n > len) > - { > - data.resize (n); > - > - for (octave_idx_type i = len; i < n; i++) > - data[i] = val; > - } > - else if (n < len) > - data.resize (n); > -} > - > octave_value_list& > octave_value_list::prepend (const octave_value& val) > { > Index: src/oct-obj.h > =================================================================== > RCS file: /cvs/octave/src/oct-obj.h,v > retrieving revision 1.48 > diff -u -r1.48 oct-obj.h > --- src/oct-obj.h 26 Apr 2005 19:24:33 -0000 1.48 > +++ src/oct-obj.h 14 Nov 2005 04:43:09 -0000 > at @ -96,7 +96,20 @@ > > void resize (octave_idx_type n) { data.resize (n); } > > - void resize (octave_idx_type n, const octave_value& val); > + void resize (octave_idx_type n, const octave_value& val) > + { > + octave_idx_type len = length (); > + > + if (n > len) > + { > + data.resize (n); > + > + for (octave_idx_type i = len; i < n; i++) > + data[i] = val; > + } > + else if (n < len) > + data.resize (n); > + } > > octave_value_list& prepend (const octave_value& val); > -- Shai Ayal, Ph.D. Head of Research BioControl Medical BCM 3 Geron St. Yehud 56100 ISRAEL Tel: + 972 3 6322 126 ext 223 Fax: + 972 3 6322 125 email: shaia at biocontrol dot co dot il ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------