| Re: Is this a bug? [message #13071 is a reply to message #12978] |
Thu, 01 October 1998 00:00   |
rmlongfield
Messages: 68 Registered: August 1998
|
Member |
|
|
In article <36129C40.297A@bial1.ucsd.edu>,
David Foster <foster@bial1.ucsd.edu> wrote:
> Platform: Sun Sparc2, Solaris 2.5 Patched
> IDL Version: 5.0.3
>
> Can someone please explain to me why the following is happening?
>
> p = ptr_new( {a:1, b:2, s:{x:0,y:0, a:[256,256,48]} } )
>
> print, ((*p).s.a)[2]
> 48
>
> ((*p).s.a)[2] = ((*p).s.a)[2] * 4
> % Temporary variables are still checked out - cleaning up...
>
> print, ((*p).s.a)[2]
> 48 ; Value was not adjusted
>
> help, ((*p).s.a)[2]
> <Expression> INT = 48
>
> print, ((*p).s.a)
> 256 256 48
>
> (*p).s.a[2] = (*p).s.a[2] * 4
>
> print, ((*p).s.a)[2]
> 192 ; Value *was* adjusted
>
> Is ((*p).s.a)[2] an invalid construct? IDL doesn't seem to have
> problems with it in the PRINT command, and it sure seems ok to
> me. The message about temporary variables seems to be a clue,
> but I need some help on this one.
>
> Thanks!
>
> Dave
> --
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
> David S. Foster Univ. of California, San Diego
> Programmer/Analyst Brain Image Analysis Laboratory
> foster@bial1.ucsd.edu Department of Psychiatry
> (619) 622-5892 8950 Via La Jolla Drive, Suite 2240
> La Jolla, CA 92037
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
>
Hi Dave, That's a pretty interesting (and disturbing) bug. I get the
same results on my SGI. The temporary variable message is a puzzle because I
ran your program just after entering IDL. Usually I get this message after a
program crashes and I forget to type RETALL. (I don't know what this does
internally, just that the book says that I should do it)
Based on my experience with pointers to structures with pointers to arrays
(ugh!), this construction: (*p).s.a[2] looks more correct than this one:
((*p).s.a)[2] , although I have never made this particular construction. I've
also noticed that IDL does not discuss all variations. However, I use PRINT
statements to check whether something is working properly. The fact that it
doesn't in your case is worrisome.
I hope someone has an answer.
Rose
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
|
|
|
|