|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
qt
Joined: 23 Aug 2005 Posts: 46 Location: Berlin, Germany
|
Posted: Thu Oct 05, 2006 5:20 pm Post subject: INTEGER overflow detection |
|
|
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 |
|
|
qt
Joined: 23 Aug 2005 Posts: 46 Location: Berlin, Germany
|
Posted: Thu Oct 05, 2006 5:22 pm Post subject: INTEGER overflow detection |
|
|
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 |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Fri Oct 06, 2006 5:14 am Post subject: INTEGER overflow detection |
|
|
Joerg
The documentation says that integer overflow is only trapped when CHECKMATE is switched on.
Regards
Paul |
|
Back to top |
|
|
qt
Joined: 23 Aug 2005 Posts: 46 Location: Berlin, Germany
|
Posted: Fri Oct 06, 2006 2:17 pm Post subject: INTEGER overflow detection |
|
|
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 |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Thu Oct 19, 2006 2:25 am Post subject: INTEGER overflow detection |
|
|
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 |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Thu Oct 19, 2006 11:26 pm Post subject: INTEGER overflow detection |
|
|
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 |
|
|
KL Guest
|
Posted: Mon Dec 18, 2006 10:49 am Post subject: |
|
|
I have rerun this problem with FTN95 v5.0 and the problem has been solved. Thank you very much!
Klaus |
|
Back to top |
|
|
|
|
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
|