From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 991DA3857829; Tue, 23 Mar 2021 21:03:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 991DA3857829 From: "pvoytas at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libfortran/99740] New: floating point exception in rand() in gfortran Date: Tue, 23 Mar 2021 21:03:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libfortran X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pvoytas at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Mar 2021 21:03:42 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99740 Bug ID: 99740 Summary: floating point exception in rand() in gfortran Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libfortran Assignee: unassigned at gcc dot gnu.org Reporter: pvoytas at gmail dot com Target Milestone: --- Possible bug in gfortran rand() function? Included code fails with IEEE divide by zero signalling.=20 When I request a backtrace, it is from a line with "-log(rand(0))".=20 Last output to the file for code included below is 0.183492497 on line 7372= 837. If I just write the rand(0) to file (not taking the log), the code finishes with no errors and the values near line 7372837 don't seem to have any weird values that would account for the error. Code runs with out errors either way if I use "call random_number(x)" to generate random numbers. Since I'm porting old code, the backward compatibi= lity of rand(0) is needed. (note: Code compiles and runs successfully with either g77 or gfortran on Centos 6.x machine with distro default gcc) gcc -v output: Using built-in specs. COLLECT_GCC=3Dgcc COLLECT_LTO_WRAPPER=3D/opt/ohpc/pub/compiler/gcc/8.3.0/libexec/gcc/x86_64-p= c-linux-gnu/8.3.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --disable-multilib --enable-languages=3Dc,c++,fortran --prefix=3D/opt/ohpc/pub/compiler/gcc/8.= 3.0 --disable-static --enable-shared Thread model: posix gcc version 8.3.0 (GCC) Distro: Oracle Linux (7.9): uname -a gives: Linux 5.4.17-2011.6.2.el7uek.x86_64 #2 SMP Thu Sep 3 14:09:14 PDT 2020 x86_64 x86_64 x86_64 GNU/Linux compile command: gfortran -ffpe-trap=3Dzero -g rantest.f compiles with no errors runtime errors: Program received signal SIGFPE: Floating-point exception - erroneous arithm= etic operation. Backtrace for this error: #0 0x7fc09a5113ff in ??? #1 0x7fc09ad330bc in ??? #2 0x4008cf in rantest at /home/pvoytas/ps_cp/accidentals/time_series/rantest.f:10 #3 0x400968 in main at /home/pvoytas/ps_cp/accidentals/time_series/rantest.f:13 Floating exception (core dumped) code: program rantest implicit none integer*4 i real*8 x do i=3D1,10000000 c call random_number(x) c write(11,*)x c write(11,*)rand(0) write(11,*)-log(rand(0)) enddo stop end=