octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

octave_value f (octave_scalar (1) )


From: Jens Ruecknagel
Subject: octave_value f (octave_scalar (1) )
Date: Fri, 23 Apr 2004 22:26:32 +0200
User-agent: Mozilla Thunderbird 0.5 (X11/20040208)

octave_value f (octave_scalar (1) );

makes octave crash.
Because the copy constructor of octave_value is called with an octave_scalar.

octave_value :: octave_value (const octave_value& a)
   {
     rep = a.rep;
     rep->count++;
   }

Because in an octave_value rep and count are put in a union.
"a.rep" on the octave_scalar "a" interprets the bit pattern of count as pointer, which is not valid. Dereferencing the pointer in the next line causes the crash. Fortunately the memory management detects it.

So probably the programmer should never call a constructor of a descendant of octave_value?
Or is this a design flaw?

Is there a simple and fast way to find out whether a given octave_value o is a octave_value or a descendant?

Thanks

Jens



reply via email to

[Prev in Thread] Current Thread [Next in Thread]