forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

INTEGER overflow detection

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
qt



Joined: 23 Aug 2005
Posts: 46
Location: Berlin, Germany

PostPosted: Thu Oct 05, 2006 5:20 pm    Post subject: INTEGER overflow detection Reply with quote

Hi Paul!

Here is another problem with the detection of INTEGER overflows.
I have tested v4.91 and proofed that the program did not catch the overflow.
CVF 6.6 and IVF 9.0 don't detect it too.

Kind regards,

Joerg
QT software


Winapp
Program Test_OutofRange

Implicit None

Integer , Parameter :: iKind = selected_int_kind (2)

Integer (iKind) :: k

write (*,*) ' Results of Program Test_OutofRange'
write (*,*) ' =================================='
write (*,*)

write (*,*) ' Kind of k = ', iKind
write (*,*) ' Huge (k) = ', Huge (k)
write (*,*)
write (*,*) ' Kind of 9999 = ', kind (9999)
write (*,*) ' Huge of 9999 = ', Huge (9999)
write (*,*)
write (*,*)

! Clearly, k = 9999 is out of range, i.e. gt 127.
! A program stop should occur.
! Instead a wrong value (k=15) is given for the variable k; please see the output.

k = 9999

! k = 9999_iKind gives an error message during compilation

write (*,*) 'The assignment statement k = 9999 gives k = ', k
write (*,*) 'without any warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'

End Program Test_OutofRange


Back to top
View user's profile Send private message Visit poster's website
qt



Joined: 23 Aug 2005
Posts: 46
Location: Berlin, Germany

PostPosted: Thu Oct 05, 2006 5:22 pm    Post subject: INTEGER overflow detection Reply with quote

Here is another program of that customer showing the INTEGER overflow occuring without any message of the compiler runtime system (CVF and IVF fail too).

Kind regards,

Joerg

Program Test_overflow

Implicit None

! For iKind = selected_int_kind (9) overflow works correctly
! ###########################################################

Integer , Parameter :: iKind = selected_int_kind (4)

Integer (iKind) :: i, k

write (*,*) ' Results of Program Test_overflow'
write (*,*) ' ================================'
write (*,*)

write (*,*) ' iKind = ', iKind
write (*,*) ' Huge (i) = ', Huge (i)
write (*,*)

! For the Do Loop index i = 5, an error message should be given and
! a program stop should occur;
! instead wrong values are given for the variable k; please see output.


k = 10_iKind
Do i = 1, 10
write (*,*) ' Do-Loop index i = ', i, ' Value of k = ', k
k = k * 10_iKind
End Do

write (*,*)
write (*,*) ' The results for Do Loop index = 5,6,...,10 are completely wrong!'
write (*,*) ' ################################################################'

End Program Test_overflow
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7927
Location: Salford, UK

PostPosted: Fri Oct 06, 2006 5:14 am    Post subject: INTEGER overflow detection Reply with quote

Joerg

The documentation says that integer overflow is only trapped when CHECKMATE is switched on.

Regards

Paul
Back to top
View user's profile Send private message AIM Address
qt



Joined: 23 Aug 2005
Posts: 46
Location: Berlin, Germany

PostPosted: Fri Oct 06, 2006 2:17 pm    Post subject: INTEGER overflow detection Reply with quote

I have tested several configurations in Plato 3. Among these CHECKMATE-Win32. I have also tried different combination of compiler switches. But none lead to a program abort when an overflow occurs. Which options should I use?
Thank you, Paul.
Joerg
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7927
Location: Salford, UK

PostPosted: Thu Oct 19, 2006 2:25 am    Post subject: INTEGER overflow detection Reply with quote

Joerg

At the moment it appears that integer overflow is not trapped on simple assignment such as k = 9999 nor k= 99*99 which is probably resolved by the compiler. This does not seem unreasonable since the programmer should be aware of this.

But it is trapped in arithmetic expressions such as

k = 99
k = k*k

We will run a few tests to see if this can be improved.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7927
Location: Salford, UK

PostPosted: Thu Oct 19, 2006 11:26 pm    Post subject: INTEGER overflow detection Reply with quote

Joerg

The response to integer overflow has now been improved under Win32.
This will be included in the next release (version 5.0).

Regards

Paul
Back to top
View user's profile Send private message AIM Address
KL
Guest





PostPosted: Mon Dec 18, 2006 10:49 am    Post subject: Reply with quote

I have rerun this problem with FTN95 v5.0 and the problem has been solved. Thank you very much!

Klaus
Back to top
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group