Fix bootstrap with GCC 4.2.1 (PR82939)

Message ID alpine.LSU.2.20.1802161109420.18265@zhemvz.fhfr.qr
State New
Headers show
Series
  • Fix bootstrap with GCC 4.2.1 (PR82939)
Related show

Commit Message

Richard Biener Feb. 16, 2018, 10:31 a.m.
After Jakubs fixes we can restore bootstrap with GCC 4.2.1 as provided
by older Darwin hosts with the following patch.

Bootstrap using a GCC 4.2.1 host compiler on x86_64-unknown-linux-gnu
is now in stage2.

Ok for trunk?

Thanks,
Richard.

2018-02-16  Richard Biener  <rguenther@suse.de>

	PR bootstrap/82939
	* line-map.c (linemap_init): Avoid broken value-init when compiling
	with GCC 4.2.

Comments

Jakub Jelinek Feb. 16, 2018, 10:40 a.m. | #1
On Fri, Feb 16, 2018 at 11:31:15AM +0100, Richard Biener wrote:
> 

> After Jakubs fixes we can restore bootstrap with GCC 4.2.1 as provided

> by older Darwin hosts with the following patch.

> 

> Bootstrap using a GCC 4.2.1 host compiler on x86_64-unknown-linux-gnu

> is now in stage2.

> 

> Ok for trunk?

> 

> Thanks,

> Richard.

> 

> 2018-02-16  Richard Biener  <rguenther@suse.de>

> 

> 	PR bootstrap/82939

> 	* line-map.c (linemap_init): Avoid broken value-init when compiling

> 	with GCC 4.2.

> 

> Index: libcpp/line-map.c

> ===================================================================

> --- libcpp/line-map.c	(revision 257728)

> +++ libcpp/line-map.c	(working copy)

> @@ -344,7 +344,12 @@ void

>  linemap_init (struct line_maps *set,

>  	      source_location builtin_location)

>  {

> +#if __GNUC__ == 4 && __GNUC_MINOR__ == 2


Please add && !defined (__clang__), because clang claims to be
exactly GCC 4.2 in all versions and as clang is system compiler these days
on Darwin and some BSDs, it is common enough we avoid the memset for
those, the memset is pedantically incorrect, just happens to work fine
with older GCCs where the value initialization doesn't.

Ok with that nit fixed.

> +  /* PR33916, needed to fix PR82939.  */

> +  memset (set, 0, sizeof (struct line_maps));

> +#else

>    *set = line_maps ();

> +#endif

>    set->highest_location = RESERVED_LOCATION_COUNT - 1;

>    set->highest_line = RESERVED_LOCATION_COUNT - 1;

>    set->location_adhoc_data_map.htab =


	Jakub

Patch

Index: libcpp/line-map.c
===================================================================
--- libcpp/line-map.c	(revision 257728)
+++ libcpp/line-map.c	(working copy)
@@ -344,7 +344,12 @@  void
 linemap_init (struct line_maps *set,
 	      source_location builtin_location)
 {
+#if __GNUC__ == 4 && __GNUC_MINOR__ == 2
+  /* PR33916, needed to fix PR82939.  */
+  memset (set, 0, sizeof (struct line_maps));
+#else
   *set = line_maps ();
+#endif
   set->highest_location = RESERVED_LOCATION_COUNT - 1;
   set->highest_line = RESERVED_LOCATION_COUNT - 1;
   set->location_adhoc_data_map.htab =