Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Is it me or is it a compiler error????
Is it me or is it a compiler error???? [message #248869] Wed, 17 October 2007 17:01 Go to next message
Eclipse UserFriend
Originally posted by: kwarner.uneedspeed.net

Hi,

I'm having a strange problem. I index into an array three different but equivalent ways. Some ways work -- one way fails with an out of bounds error. Let me attempt to explain --


This is the orignial code I am trying to simplfy and it works fine -- sy, sxL and sxR are properly initialized in earlier code.

This works just fine
desPixels[y + xL] = srcPixels[(sy * imageW) + sxL]; desPixels[y + xR] = srcPixels[(sy * imageW) + sxR];


This form also works
sy *= imageW;
tempL = sy + sxL;
tempR = sy + sxR;
desPixels[y + xL] = srcPixels[tempL];
desPixels[y + xR] = srcPixels[tempR];


This form works too
sy *= imageW;
desPixels[y + xL] = srcPixels[sy + sxL];
desPixels[y + xR] = srcPixels[sy + sxR];


This form DOES NOT WORK <<<<<<<< out of bounds error
sy *= imageW;
sxL = sy + sxL;
sxR = sy + sxR;
desPixels[y + xL] = srcPixels[sxL];
desPixels[y + xR] = srcPixels[sxR];

I just don't see the problem. Is something being optimized away? Or am I just going cross eyed?

DemonDuck
Re: Is it me or is it a compiler error???? [message #248874 is a reply to message #248869] Wed, 17 October 2007 17:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kwarner.uneedspeed.net

Sorry --

Eclipse 3.2.2; Windows 2000 SP4; Java 1.5.0.9

DemonDuck wrote:
> Hi,
>
> I'm having a strange problem. I index into an array three different but
> equivalent ways. Some ways work -- one way fails with an out of bounds
> error. Let me attempt to explain --
>
> This is the orignial code I am trying to simplfy and
> it works fine -- sy, sxL and sxR are properly initialized in earlier code.
>
> This works just fine
> desPixels[y + xL] = srcPixels[(sy * imageW) +
> sxL]; desPixels[y + xR] =
> srcPixels[(sy * imageW) + sxR];
>
> This form also works
> sy *= imageW;
> tempL = sy + sxL;
> tempR = sy + sxR;
> desPixels[y + xL] = srcPixels[tempL];
> desPixels[y + xR] = srcPixels[tempR];
>
>
> This form works too
> sy *= imageW;
> desPixels[y + xL] = srcPixels[sy + sxL];
> desPixels[y + xR] = srcPixels[sy + sxR];
>
>
> This form DOES NOT WORK <<<<<<<< out of bounds error
> sy *= imageW;
> sxL = sy + sxL;
> sxR = sy + sxR;
> desPixels[y + xL] = srcPixels[sxL];
> desPixels[y + xR] = srcPixels[sxR];
>
> I just don't see the problem. Is something being optimized away? Or am
> I just going cross eyed?
>
> DemonDuck
Re: Is it me or is it a compiler error???? [message #248879 is a reply to message #248869] Wed, 17 October 2007 19:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Hi,

Is this in a loop of some kind that it fails?

If it is in a loop, you are changing sxL and sxR so that on the next
iteration of the loop they would have a new value when being added to
sy. Unless you reset sxL and sxR on each iteration. The previous forms
were not changing sxL and sxR so that on each iteration of the loop they
have the same value.

Also you are changing sy each time in the loop too. Is it reset on each
iteration of the loop so that sy*=imageW results in a good value?

>
> This form DOES NOT WORK <<<<<<<< out of bounds error
> sy *= imageW;
> sxL = sy + sxL;
> sxR = sy + sxR;
> desPixels[y + xL] = srcPixels[sxL];
> desPixels[y + xR] = srcPixels[sxR];
>
> I just don't see the problem. Is something being optimized away? Or am
> I just going cross eyed?
>
> DemonDuck

--
Thanks,
Rich Kulp
Re: Is it me or is it a compiler error???? [message #248883 is a reply to message #248879] Wed, 17 October 2007 19:20 Go to previous message
Eclipse UserFriend
Originally posted by: kwarner.uneedspeed.net

I'm so embarassed! It's in a double for loop and sxL and sxR are outside
the inter loop. Sometimes I get so tired I can't see the code...

Thanks for the kick in the butt....

Rich Kulp wrote:
> Hi,
>
> Is this in a loop of some kind that it fails?
>
> If it is in a loop, you are changing sxL and sxR so that on the next
> iteration of the loop they would have a new value when being added to
> sy. Unless you reset sxL and sxR on each iteration. The previous forms
> were not changing sxL and sxR so that on each iteration of the loop they
> have the same value.
>
> Also you are changing sy each time in the loop too. Is it reset on each
> iteration of the loop so that sy*=imageW results in a good value?
>
>>
>> This form DOES NOT WORK <<<<<<<< out of bounds error
>> sy *= imageW;
>> sxL = sy + sxL;
>> sxR = sy + sxR;
>> desPixels[y + xL] = srcPixels[sxL];
>> desPixels[y + xR] = srcPixels[sxR];
>>
>> I just don't see the problem. Is something being optimized away? Or
>> am I just going cross eyed?
>>
>> DemonDuck
>
>
Previous Topic:[Quick Assist] Quick assist fails in else-if expression
Next Topic:How to add a new class to a package
Goto Forum:
  


Current Time: Mon Jul 14 14:39:25 EDT 2025

Powered by FUDForum. Page generated in 0.05094 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top