Silverfrost Forums

Welcome to our forums

Bug with optimise?

24 May 2014 8:24 #14116

Hi,

I think I have a bug with /optimise. The following function performs differently with compiled with and without the option. Essentially it is supposed to remove any leading spaces from a character string and append a letter 'A'.

I correctly get 'helloA' without optimise. But with it I get 'hello @'.

Note - I've found several ways to re-write the code that do let it compile correctly with /optimise, so it must be something specific about this structure. (Even adding a PRINT *,J into the inner loop fixes it. Also note - this is a simplified example to highlight the problem - so no need to suggest ways to improve the code!

Thanks, Mark.

character10 :: qqq character10 :: a,b a=' hello' b=qqq(a) print *,a print *,b end

character10 function qqq(a) implicit none character10 :: a integer :: i,j do i=1,9 if(a(i:i)/=' ') then do j=i+1,10 if(a(j:j)==' ') then qqq=a(i:j-1)//'A' return end if end do end if end do qqq='XXXXXXXXXX' return end

24 May 2014 8:29 #14117

Forgot to say - I'm using V7.00.0

25 May 2014 8:33 #14119

This is clearly a bug but to optimise this code you should use the standard intrinsic ADJUSTL.

Please login to reply.