This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix miscompilation of initializers with flexible arraymembers (regression from 3.4, PR tree-optimization/22043, take 2)

Jakub Jelinek wrote:
On Mon, Jun 13, 2005 at 06:39:18PM -0400, Jakub Jelinek wrote:

store_constructor ignores clearing for variable sized types, and
Ada is apparently initializing variable-sized objects with constructors.
I did not manage to do that in C or C++, apparently initializers for
variable-sized types are forbidden there.
So, if we can hope that Ada makes sure there are no gaps when initializing
variable-sized types or doesn't care, attached are 2 improved patches
that only set cleared if num_type_elements < 0 for constant-sized objects.

The first one (shorter) has been bootstrapped/regtested on 4.0 branch

The short version is OK for 4.0. But, would you mind removing the blank line here?

+	if (num_type_elements < 0 && int_size_in_bytes (type) >= 0)
+	  cleared = true;

 	/* If there are "lots" of zeros, then block clear the object first.  */
-	if (num_type_elements - num_nonzero_elements > CLEAR_RATIO
-	    && num_nonzero_elements < num_type_elements/4)
+	else if (num_type_elements - num_nonzero_elements > CLEAR_RATIO
+		 && num_nonzero_elements < num_type_elements/4)

on ppc64-linux and s390-linux, the latter on HEAD on i386-linux.

I think the longer version should probably be integrated with count_type_elements, by passing a flag saying that you want special treatment for flexible arrays. Otherwise, you're duplicating the logic of count_type_elements, as well as walking the type twice at runtime. The short version would be OK for mainline too, if you're not eager to do more work here.


Mark Mitchell
CodeSourcery, LLC
(916) 791-8304

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]