This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/28105] Check for memory allocations bigger than size_t
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 1 Dec 2010 15:39:32 +0000
- Subject: [Bug fortran/28105] Check for memory allocations bigger than size_t
- Auto-submitted: auto-generated
- References: <bug-28105-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28105
--- Comment #9 from Tobias Burnus <burnus at gcc dot gnu.org> 2010-12-01 15:38:52 UTC ---
(In reply to comment #8)
> For automatic and static arrays, different code paths are chosen.
I think one should try to get some checking working for INTEGER_CST_P only,
i.e. independent whether one uses automatic or static arrays or in the ALLOCATE
statement, a compile-time error should be printed. I am not sure that one needs
a run-time error - and if so, only with -fcheck=mem.
I think one should do something like:
if (INTEGER_CST_P (size))
{
if (!host_integerp (DECL_SIZE_UNIT (size), 1))
goto too_large = true;
if (TREE_INT_CST_LOW (size)
> TYPE_MAX_VALUE (sizetype)/TREE_INT_CST_LOW (element_size)
goto too_large;
}
if (!host_integerp (DECL_SIZE_UNIT (decl), 1))
goto too_large;
too_large:
gfc_error (...);