Reply to topic  [ 2 posts ] 
something wrong with the off argument in strgrep 
Author Message
Yorick Guru

Joined: Thu May 10, 2007 12:07 pm
Posts: 62
Post something wrong with the off argument in strgrep
A small but weird bug, easy to surround. The offset argument is not sent correctly into the strgrep function :

Code:
> str = "abcdef"(-:1:20); offset = array( int , 20);  ou = indgen(20);

> strgrep("a", str , offset) /* OK  */
[[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],
[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1]]

> strgrep("a", str , offset(ou)) /* NOT OK */
[[0,1],[0,1],[0,1],[0,1],[6,-1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,
1],[0,1],[6,-1],[0,1],[0,1],[6,-1],[6,-1],[0,1]]

> strgrep("a", str , (tmp=offset(ou)) )  /* OK */
[[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],
[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1]]

> strgrep("a", str , long(offset(ou)) ) /* OK */
[[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],
[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1]]



I have absolutely no idea what is going wrong. If offset is declared as long array they are no problems.
Sylvain.


Mon Feb 23, 2009 2:41 pm
Profile
Yorick Master

Joined: Mon Nov 22, 2004 9:43 am
Posts: 354
Location: Livermore, CA, USA
Post 
I can't reproduce this.

What kind of machine is this run on, and precisely what yorick version?

The bug is very unlikely to be in the strgrep function. Several questions occur to me:

1. Does this ever happen if the offset array is correctly declared as a long, offset=array(long,20)? The int type in yorick (or in C for that matter) is not the correct data type for array indices, so you are forcing a type conversion whenever you use it for that purpose. (That is why x=0 in yorick defiens a long, not an int. The int type is only used for boolean values in yorick.)

2. How special is the 20? What happens if you use a random permutation instead of indgen(20), e.g.- ou=sort(random(20)).

3. Does the bug persist if yu run it under a debugging version of yorick, built with -g instead of -O? If not, this is a complier bug. If so, it may be a subtle yorick bug that only occurs on your platform, or it could still be a compiler bug.

4. If you do build a debugging yorick, it should be fairly easy to narrow down the problem a lot more, by just stepping through Y_strgrep and watching what goes wrong. I'm guessing the offset argument starts out correct, but is corrupted during the type conversion as the argument is retrieved. Please let me know what you find if you do step through it.


Tue Feb 24, 2009 8:48 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.