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

Reply via email to