public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pvoytas at gmail dot com" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-99740-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99740 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. When I request a backtrace, it is from a line with "-log(rand(0))". Last output to the file for code included below is 0.183492497 on line 7372837. 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 compatibility 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=gcc COLLECT_LTO_WRAPPER=/opt/ohpc/pub/compiler/gcc/8.3.0/libexec/gcc/x86_64-pc-linux-gnu/8.3.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --disable-multilib --enable-languages=c,c++,fortran --prefix=/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 <hostname> 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=zero -g rantest.f compiles with no errors runtime errors: Program received signal SIGFPE: Floating-point exception - erroneous arithmetic 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=1,10000000 c call random_number(x) c write(11,*)x c write(11,*)rand(0) write(11,*)-log(rand(0)) enddo stop end
next reply other threads:[~2021-03-23 21:03 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-23 21:03 pvoytas at gmail dot com [this message] 2021-03-23 21:59 ` [Bug libfortran/99740] " anlauf at gcc dot gnu.org 2021-03-23 22:02 ` kargl at gcc dot gnu.org 2021-03-25 12:52 ` pvoytas at gmail dot com 2021-03-25 17:17 ` sgk at troutmask dot apl.washington.edu 2021-03-29 14:43 ` pvoytas at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-99740-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).