diff mbox series

bootstrap: Fix building with GCC 4.2 [PR89494]

Message ID 20200416070157.GF2424@tucnak
State New
Headers show
Series bootstrap: Fix building with GCC 4.2 [PR89494] | expand

Commit Message

Jakub Jelinek April 16, 2020, 7:01 a.m. UTC
Hi!

GCC 4.2 (but I think not the latest tip of GCC 4.2 branch) has broken value
initialization, see PR33916.  The following patch provides a workaround for
that.  Tested with GCC 4.2 on a reduced testcase I've distilled from the
assign_param_data_one class which has been miscompiled the same,
and normally bootstrapped/regtested on x86_64-linux and i686-linux with
a recentish system GCC.  Ok for trunk?

2020-04-16  Jakub Jelinek  <jakub@redhat.com>

	PR bootstrap/89494
	* function.c (assign_parm_find_data_types): Add workaround for
	BROKEN_VALUE_INITIALIZATION compilers.


	Jakub

Comments

Richard Biener April 16, 2020, 7:22 a.m. UTC | #1
On Thu, 16 Apr 2020, Jakub Jelinek wrote:

> Hi!
> 
> GCC 4.2 (but I think not the latest tip of GCC 4.2 branch) has broken value
> initialization, see PR33916.  The following patch provides a workaround for
> that.  Tested with GCC 4.2 on a reduced testcase I've distilled from the
> assign_param_data_one class which has been miscompiled the same,
> and normally bootstrapped/regtested on x86_64-linux and i686-linux with
> a recentish system GCC.  Ok for trunk?

OK.

Richard.

> 2020-04-16  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR bootstrap/89494
> 	* function.c (assign_parm_find_data_types): Add workaround for
> 	BROKEN_VALUE_INITIALIZATION compilers.
> 
> --- gcc/function.c.jj	2020-01-12 11:54:36.606410497 +0100
> +++ gcc/function.c	2020-04-15 14:15:29.269495427 +0200
> @@ -2414,7 +2414,15 @@ assign_parm_find_data_types (struct assi
>  {
>    int unsignedp;
>  
> +#ifndef BROKEN_VALUE_INITIALIZATION
>    *data = assign_parm_data_one ();
> +#else
> +  /* Old versions of GCC used to miscompile the above by only initializing
> +     the members with explicit constructors and copying garbage
> +     to the other members.  */
> +  assign_parm_data_one zero_data = {};
> +  *data = zero_data;
> +#endif
>  
>    /* NAMED_ARG is a misnomer.  We really mean 'non-variadic'. */
>    if (!cfun->stdarg)
> 
> 	Jakub
> 
>
diff mbox series

Patch

--- gcc/function.c.jj	2020-01-12 11:54:36.606410497 +0100
+++ gcc/function.c	2020-04-15 14:15:29.269495427 +0200
@@ -2414,7 +2414,15 @@  assign_parm_find_data_types (struct assi
 {
   int unsignedp;
 
+#ifndef BROKEN_VALUE_INITIALIZATION
   *data = assign_parm_data_one ();
+#else
+  /* Old versions of GCC used to miscompile the above by only initializing
+     the members with explicit constructors and copying garbage
+     to the other members.  */
+  assign_parm_data_one zero_data = {};
+  *data = zero_data;
+#endif
 
   /* NAMED_ARG is a misnomer.  We really mean 'non-variadic'. */
   if (!cfun->stdarg)