public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/28105]  New: Check for memory allocations bigger than size_t
@ 2006-06-20 19:01 tobias dot burnus at physik dot fu-berlin dot de
  2007-02-14 15:43 ` [Bug fortran/28105] " manu at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: tobias dot burnus at physik dot fu-berlin dot de @ 2006-06-20 19:01 UTC (permalink / raw)
  To: gcc-bugs

sizeof(size_t) on ia32 is 4 thus 2^32 = 4,294,967,296 Byte can be accessed by
unsigned.
   real(4), dimension(1025*1024*1024) :: m
can thus not be accessed on ia32. Currently, gfortran does detect this overflow
at compile time.

Expected: The same as ifort:
fortcom: Error: mem.f, line 3: A common block or variable may not exceed
2147483647 bytes
      REAL(4), DIMENSION(1074790400) :: T
-----------------------------------^)

(2147483647 = 2^31-1 -> signed int32.)

Analogously for allocate() of pointers and arrays. Currently this does not fail
even if sizeof(datatype)*size overflows size_t. As size_t is always possitive,
the malloc() works sucessfully. In my case it produces:
1074790400*4 = 4194304. I get a coredump if I access T(1048577) as I only
allocated T(1:1048576:1).

Other compilers seem to have an overflow check somewhere. Maybe it works the
following [symbolically written]
  if(size > 2**sizeof(size_t)/sizeof(datatype)) call error()
at least they return a non-successful status with allocate.


-- 
           Summary: Check for memory allocations bigger than size_t
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tobias dot burnus at physik dot fu-berlin dot de


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


^ permalink raw reply	[flat|nested] 13+ messages in thread
[parent not found: <bug-28105-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2013-06-22 13:55 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-20 19:01 [Bug fortran/28105] New: Check for memory allocations bigger than size_t tobias dot burnus at physik dot fu-berlin dot de
2007-02-14 15:43 ` [Bug fortran/28105] " manu at gcc dot gnu dot org
2007-04-18  6:06 ` fxcoudert at gcc dot gnu dot org
2009-04-15 12:30 ` dfranke at gcc dot gnu dot org
     [not found] <bug-28105-4@http.gcc.gnu.org/bugzilla/>
2010-11-19 23:49 ` jb at gcc dot gnu.org
2010-11-22 22:46 ` jb at gcc dot gnu.org
2010-11-30 21:53 ` jb at gcc dot gnu.org
2010-12-01 11:04 ` burnus at gcc dot gnu.org
2010-12-01 14:44 ` jb at gcc dot gnu.org
2010-12-01 15:39 ` burnus at gcc dot gnu.org
2010-12-02  7:35 ` Joost.VandeVondele at pci dot uzh.ch
2010-12-15 17:15 ` jb at gcc dot gnu.org
2013-06-22 13:55 ` dominiq at lps dot ens.fr

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