public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "J dot Hogg at rl dot ac dot uk" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/36153]  New: ICE on size with kind parameter
Date: Tue, 06 May 2008 11:06:00 -0000	[thread overview]
Message-ID: <bug-36153-15996@http.gcc.gnu.org/bugzilla/> (raw)

Use of an optional kind parameter on a call to the intrinsic size was added in
Fortran 2003, and is essential to avoid overflow when dealing with arrays
bigger than huge(0). The following example provides test code and demonstrates
this.
gfortran should warn that this is non-standard fortran 90/95 and fail
gracefully, and/or work as per the F2003 spec.

Thanks,
Jonathan.

[user@host] ~/bugs/gfortran-4.3/size_kind  $ gfortran-4.3 -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --program-suffix=-4.3
Thread model: posix
gcc version 4.3.0 (GCC)
[user@host] ~/bugs/gfortran-4.3/size_kind  $ gfortran-4.3 test_64.f90 
f951: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
[user@host] ~/bugs/gfortran-4.3/size_kind  $ cat test_64.f90 
program test_64
   implicit none

   integer, parameter :: long = selected_int_kind(18)
   integer, parameter :: short = kind(0)

   integer(long), parameter :: big_sz = huge(0_short)+1000_long
   integer(long), parameter :: max_32 = huge(0_short)
   integer, dimension(:), allocatable :: array

   integer(long) :: i

   print *, "2**31  = ", 2_long**31
   print *, "max_32 = ", max_32
   print *, "big_sz = ", big_sz

   allocate(array(big_sz))
   print *, "sz = ", size(array)
   print *, "sz = ", size(array, kind=long)
end program


-- 
           Summary: ICE on size with kind parameter
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: J dot Hogg at rl dot ac dot uk
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36153


             reply	other threads:[~2008-05-06 11:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-06 11:06 J dot Hogg at rl dot ac dot uk [this message]
2008-05-06 14:43 ` [Bug fortran/36153] " burnus at gcc dot gnu dot org
2008-05-06 15:18 ` kargl at gcc dot gnu dot org
2008-08-29 23:21 ` [Bug fortran/36153] ICE on size with kind parameter [F2003] kargl at gcc dot gnu dot org
2008-09-06 15:30 ` burnus at gcc dot gnu dot org
2008-09-06 15:57 ` burnus at gcc dot gnu dot org

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-36153-15996@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: link
Be 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).