UNREVIEWED PATCH: char array initialization - simplified

John David Anglin dave@hiauly1.hia.nrc.ca
Fri Aug 3 08:53:00 GMT 2001


> Why not just use 
> 
> MAX (TREE_STRING_LENGTH (exp), int_size_in_bytes (TREE_TYPE (exp)))
> 
> for all STRING_CSTs?

I revised the patch per your suggestion.  Tested with a complete bootstrap
and check with the mainline code on i686-pc-linux-gnu.  There were no
obvious regression and 20000801-4.c is still a XPASS.  The previous version
of the patch was tested with the main and branch code on hppa1.1-hp-hpux10.20,
and with the branch code on vax-dec-ultrix4.3.

I have verified that there are situations where TREE_STRING_LENGTH (exp)
is greater than int_size_in_bytes (TREE_TYPE (exp)) and vice versa, so no
further simplification is possible.

Is it now ok for main and branch?

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2001-08-02  John David Anglin  <dave@hiauly1.hia.nrc.ca>

	* varasm.c (output_constant_def_contents): Use for the length of a
	string constant declared as an array either its array size or its
	string length depending on which is larger.

--- varasm.c.orig	Wed Aug  1 18:47:09 2001
+++ varasm.c	Thu Aug  2 17:06:02 2001
@@ -3116,7 +3116,8 @@
   /* Output the value of EXP.  */
   output_constant (exp,
 		   (TREE_CODE (exp) == STRING_CST
-		    ? TREE_STRING_LENGTH (exp)
+		    ? MAX (TREE_STRING_LENGTH (exp),
+			   int_size_in_bytes (TREE_TYPE (exp)))
 		    : int_size_in_bytes (TREE_TYPE (exp))));
 
 }



More information about the Gcc-patches mailing list