BUG: Access Violation/Hang on Divide by Zero with IntrinsicLast reviewed: December 10, 1995Article ID: Q108409 |
The information in this article applies to:
SYMPTOMSThe following error may not be produced when a divide by zero exception involving an intrinsic function occurs at run time:
run-time error M6103: MATH floating-point error: divide by 0If such a program is compiled with the -Ox option, a Dr. Watson "Application Error" message box specifying "Exception: access violation" may be generated. Otherwise, the application may hang. The following occurs using Fortran PowerStation 32, version 4.0:
CAUSEThis unexpected behavior occurs when the divide by zero exception occurs in the argument list of the SIN, COS, or SQRT intrinsic functions. ABS, EXP, and TAN also produce incorrect behavior that is slightly different from the behavior mentioned above.
RESOLUTIONExplicitly check denominators in arguments to the SIN, COS, TAN, ABS, EXP, or SQRT intrinsic function for zero values before performing a divide operation.
STATUSMicrosoft has confirmed this to be a problem in the products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONThe intrinsic function ABS generates the appropriate run-time error regardless of optimization. The intrinsic function EXP generates the appropriate run-time error with -Ox, and hangs otherwise. The intrinsic function TAN returns 0 (zero) with -Ox, and hangs otherwise. For this particular function, the compiler may generate the following warning when compiling with /Ox:
warning F4723: potential divide by 0The following sample code illustrates the symptoms described above:
Sample CodeC Compile options needed: -Ox causes an Application Error to occur C Compile options needed: none causes the application to hang
a = 0. b = 1. write (*,*) a,b !no effect when commented out c= SQRT(b/a) !GPF here write (*,*) a,b,c !no effect when commented out end |
Additional reference words: 1.00 4.00 lock halt gp-fault
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |