[C/C++ PATCH] Reject declarators with huge arrays (PR c/68107, c++/68266)

Paolo Carlini paolo.carlini@oracle.com
Tue Nov 10 17:38:00 GMT 2015


  Hi,

On 11/10/2015 05:36 PM, Marek Polacek wrote:
> +
> +		/* Did array size calculations overflow or does the array
> +		   cover more than half of the address-space?  */
> +		if (COMPLETE_TYPE_P (type)
> +		    && TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST
> +		    && !valid_constant_size_p (TYPE_SIZE_UNIT (type)))
> +		  {
> +		    if (name)
> +		      error_at (loc, "size of array %qE is too large", name);
> +		    else
> +		      error_at (loc, "size of unnamed array is too large");
> +		    type = error_mark_node;
> +		  }
>   	      }
Obviously "the issue" predates your proposed change, but I don't 
understand why the code implementing the check can't be shared by the 
front-ends via a small function in c-family...

Paolo.



More information about the Gcc-patches mailing list