public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/96711] New: Internal Compiler Error on NINT() Function
@ 2020-08-19 15:18 bre08 at eggen dot co.uk
  2020-08-19 15:21 ` [Bug fortran/96711] " bre08 at eggen dot co.uk
                   ` (23 more replies)
  0 siblings, 24 replies; 25+ messages in thread
From: bre08 at eggen dot co.uk @ 2020-08-19 15:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96711

            Bug ID: 96711
           Summary: Internal Compiler Error on NINT() Function
           Product: gcc
           Version: 9.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bre08 at eggen dot co.uk
  Target Milestone: ---

Created attachment 49082
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49082&action=edit
This recreates the error, either the internal compiler error (line 18), or, if
the previous line is activated instead, the incorrect behaviour

Hello,

I've come across an internal compiler error (in GFortran), concerning the
function NINT(), I attach a very simple source code that illustrates the error.
 Essentially I am working with 16-byte integers (ie 128-bit width), and there
seems no way to ensure that NINT() returns the correct precision integer. I
also checked on Ubuntu-64, same GCC & GFortran version (9.3.0) and I get the
same error message / behaviour.

I tried a number of things, to no avail:

1)  m=nint(y) ! this gives at best an 8 byte integer return and or larger
numbers is negative,  
2)  m=nint(y,i16) ! this is the attached version, which generates compiler
error
3)  m=nint(y,kind=i16) ! also generates error
4)  integer(kind=16) :: nint; ... m=nint(y) ! does not change return type
5)  trying to compile with "-fdefault-integer-16" # option does not exist 

Compiling with "-fdefault-integer-8" gets me a bit further, but I really
require the nint function to work for 16-byte integers.

Interestingly, in the related function, IDNINT() the "KIND" optional argument
does not even seem to be implemented.  I would probably need a working version
from real(kind=16) to integer(kind=16).

The GCC bug site stipulates:

Please include all of the following items, the first three of which can be
obtained from the output of gcc -v:

the exact version of GCC;
the system type; (Cygwin 64 on top of Windows 10)
the options given when GCC was configured/built;

-> cygcheck -c cygwin
Cygwin Package Information
Package              Version        Status
cygwin               3.1.6-1        OK

-> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with:
/cygdrive/i/szsz/tmpp/gcc/gcc-9.3.0-2.x86_64/src/gcc-9.3.0/configure
--srcdir=/cygdrive/i/szsz/tmpp/gcc/gcc-9.3.0-2.x86_64/src/gcc-9.3.0
--prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc
--docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C
--build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin
--without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib
--enable-shared --enable-shared-libgcc --enable-static
--enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit
--with-dwarf2 --with-tune=generic
--enable-languages=c,c++,fortran,lto,objc,obj-c++ --enable-graphite
--enable-threads=posix --enable-libatomic --enable-libgomp --enable-libquadmath
--enable-libquadmath-support --disable-libssp --enable-libada --disable-symvers
--with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl
--without-libiconv-prefix --without-libintl-prefix --with-system-zlib
--enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible
--enable-libstdcxx-filesystem-ts
Thread model: posix
gcc version 9.3.0 (GCC)

and for Gfortran:

-> gfortran --version
GNU Fortran (GCC) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

-> gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with:
/cygdrive/i/szsz/tmpp/gcc/gcc-9.3.0-2.x86_64/src/gcc-9.3.0/configure
--srcdir=/cygdrive/i/szsz/tmpp/gcc/gcc-9.3.0-2.x86_64/src/gcc-9.3.0
--prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc
--docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C
--build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin
--without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib
--enable-shared --enable-shared-libgcc --enable-static
--enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit
--with-dwarf2 --with-tune=generic
--enable-languages=c,c++,fortran,lto,objc,obj-c++ --enable-graphite
--enable-threads=posix --enable-libatomic --enable-libgomp --enable-libquadmath
--enable-libquadmath-support --disable-libssp --enable-libada --disable-symvers
--with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl
--without-libiconv-prefix --without-libintl-prefix --with-system-zlib
--enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible
--enable-libstdcxx-filesystem-ts
Thread model: posix
gcc version 9.3.0 (GCC)
the complete command line that triggers the bug; see below
the compiler output (error messages, warnings, etc.); see below and
the preprocessed file (*.i*) that triggers the bug, generated by adding
-save-temps to the complete compilation command, or, in the case of a bug
report for the GNAT front end, a complete set of source files (see below).
-> gfortran -save-temps -o nint_error.e nint_error.f90
nint_error.f90:17:0:

   17 |      m=nint(y,i16)
      |
internal compiler error: in build_round_expr, at fortran/trans-intrinsic.c:396
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.

(and with IDNINT()):

-> gfortran -save-temps -o nint_error.e nint_error.f90
nint_error.f90:17:7:

   17 |      m=idnint(y,i16)
      |       1
Error: Too many arguments in call to ‘idnint’ at (1)

Thanks for looking into this, Bernd (Eggen)  

PS Here a part of the output if omitting the "KIND" optional argument in NINT()
to get it to compile:


-> ./nint_error.e | & more
i16= 16
1 1 1.0000000000000000 0
2 2 2.0000000000000000 1
3 4 4.0000000000000000 3
4 8 8.0000000000000000 7
[...]
31 1073741824 1073741824.0000000 1073741823
32 2147483648 2147483648.0000000 2147483647
33 4294967296 4294967296.0000000 -1

As you can see, after 2^31-1 = 2147483647 it goes wrong and yields -1

If increasing the integer by 1, it goes wrong thus:

[...]
2147483647 2147483647.0000000 2147483647
2147483648 2147483648.0000000 -2147483648
[...]

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2021-07-23 19:59 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-19 15:18 [Bug fortran/96711] New: Internal Compiler Error on NINT() Function bre08 at eggen dot co.uk
2020-08-19 15:21 ` [Bug fortran/96711] " bre08 at eggen dot co.uk
2020-08-19 15:25 ` bre08 at eggen dot co.uk
2020-08-19 15:26 ` bre08 at eggen dot co.uk
2020-08-19 17:28 ` kargl at gcc dot gnu.org
2020-08-19 18:12 ` kargl at gcc dot gnu.org
2020-08-19 19:37 ` anlauf at gcc dot gnu.org
2020-08-19 20:11 ` toon at moene dot org
2020-08-19 21:36 ` anlauf at gcc dot gnu.org
2020-08-19 22:04 ` sgk at troutmask dot apl.washington.edu
2020-08-20 13:47 ` bre08 at eggen dot co.uk
2020-08-20 15:39 ` sgk at troutmask dot apl.washington.edu
2020-08-20 15:54 ` bre08 at eggen dot co.uk
2020-08-20 16:58 ` sgk at troutmask dot apl.washington.edu
2020-08-25 20:29 ` anlauf at gcc dot gnu.org
2020-09-07 19:42 ` cvs-commit at gcc dot gnu.org
2020-10-07  7:19 ` schwab@linux-m68k.org
2020-10-07 14:53 ` sgk at troutmask dot apl.washington.edu
2020-10-07 14:59 ` schwab@linux-m68k.org
2020-10-07 15:22 ` kargl at gcc dot gnu.org
2020-10-07 15:26 ` schwab@linux-m68k.org
2020-10-07 21:32 ` anlauf at gcc dot gnu.org
2021-05-20  8:12 ` burnus at gcc dot gnu.org
2021-05-20  9:21 ` bernd.eggen at gmail dot com
2021-07-23 19:59 ` anlauf at gcc dot gnu.org

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).