Problem concatenating structures.

John W. Eaton jwe at bevo.che.wisc.edu
Thu Jul 31 11:10:56 CDT 2008


On 31-Jul-2008, David Bateman wrote:

| I have little time to look at this at the moment, but wanted to document 
| an issue I'm having with structure concatenation. Consider the code
| 
| s = warning("query","Octave:imag-to-real")
| [s, s]
| [warning("query","Octave:imag-to-real"), 
| warning("query","Octave:imag-to-real")]
| [s, warning("query","Octave:imag-to-real")]
| [warning("query","Octave:imag-to-real"),s]
| 
| With a build from the hg tip I see
| 
| octave:1> s = warning("query","Octave:imag-to-real")
| s =
| {
|   identifier = Octave:imag-to-real
|   state = off
| }
| 
| octave:2> [s, s]
| ans =
| {
|   1x2 struct array containing the fields:
| 
|     identifier
|     state
| }
| 
| octave:3> [warning("query","Octave:imag-to-real"), 
| warning("query","Octave:imag-to-real")]
| error: invalid row index = 121
| error: caught execution error in library function
| octave:3> [s, warning("query","Octave:imag-to-real")]
| error: invalid row index = 121
| error: caught execution error in library function
| octave:3> [warning("query","Octave:imag-to-real"), s]
| error: invalid row index = 121
| error: caught execution error in library function
| 
| I see no reason for this difference, and valgrind doesn't report and 
| error, but its stopping me implementing the intwarning function.. Any 
| ideas of the cause?

I see this behavior:

  octave:1> warning("query","Octave:imag-to-real") 
  ans =
  {
    identifier = Octave:imag-to-real
    state = off
  }

  octave:2> warning
  ans =
  {
    1x15 struct array containing the fields:

      identifier
      state
  }

  octave:3> whos
  Variables in the current scope:

    Attr Name        Size                     Bytes  Class
    ==== ====        ====                     =====  ===== 
	 ans         1x15                       373  struct

  Total is 15 elements using 373 bytes

  octave:4> [warning("query","Octave:imag-to-real")]
  error: invalid row index = 121
  error: caught execution error in library function
  octave:4> warning
  warning = [](0x0)
  octave:5> whos
  Variables in the current scope:

    Attr Name         Size                     Bytes  Class
    ==== ====         ====                     =====  ===== 
	 ans          1x15                       373  struct
	 warning      0x0                          0  double

  Total is 15 elements using 373 bytes

I'm not sure yet what is causing warning to be assigned, but I'll see
if I can find out and fix it.

jwe


More information about the Bug-octave mailing list