0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

gfortranで落ちてifortで落ちないシンプルなコード。原因は不明

Posted at

Fortranのコンパイラgfortranでよくわからない挙動が起きたので情報をシェアしたいと思います。

Mac:
gcc version 9.2.0 (Homebrew GCC 9.2.0)

Ubuntu 16:
gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~16.04~ppa1)
で確認しました。

test.f90
program main
    implicit none
    complex(8)::g   
    g = 0d0 
    write(*,*) g**1d0
end program main

このコードは、gfortranでコンパイル:

gfortran test.f90 "-ffpe-trap=zero" -O0

するとなぜか

Program received signal SIGFPE: Floating-point exception - erroneous arithmetic operation.

Backtrace for this error:
#0  0x10bb51f3d
#1  0x10bb5134d
#2  0x7fff6c701b5c
Floating point exception: 8

というエラーで落ちます。

ifortだと落ちません。
原因は不明です。

 gfortran test.f90 "-ffpe-trap=invalid" -O0

だと

Program received signal SIGFPE: Floating-point exception - erroneous arithmetic operation.

Backtrace for this error:
#0  0x10142ef3d
#1  0x10142e34d
#2  0x7fff6c701b5c
#3  0x7fff6c6924cf
#4  0x101423e1b
#5  0x101423e9e

と落ちます。

何が原因なのでしょう。

0
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?