Patchwork [c++] : 1 of 7 Fix for PR target/53912 bootstrap fails using default c++ mode in stage 2 and 3 for native x86_64-w64-mingw32

login
register
mail settings
Submitter Kai Tietz
Date Nov. 29, 2012, 12:03 p.m.
Message ID <CAEwic4YFOVyfQ8r-gsKTGMxOBEjKUSkTRx4phY6UPPgHOFCK4w@mail.gmail.com>
Download mbox | patch
Permalink /patch/202722/
State New
Headers show

Comments

Kai Tietz - Nov. 29, 2012, 12:03 p.m.
Hello,

this trivial patch fixes a bootstrap issue on LLP64 hosts.

	cp/
	
	PR target/53912
	* class.c (dump_class_hierarchy_r): Cast from pointer via uintptr_t.
	(dump_vtable): Likewise.

Tested for i686-w64-mingw32, x86_64-w64-mingw32, and
x86_64-unknown-gnu-linux. Ok for apply?

Regards,
Kai
Pedro Alves - Nov. 29, 2012, 12:24 p.m.
On 11/29/2012 12:03 PM, Kai Tietz wrote:
> Hello,
> 
> this trivial patch fixes a bootstrap issue on LLP64 hosts.

But it's trivial at the expense of truncating the pointer.
Looking around, I'd think that something like casting to hwi (after uintptr_t),
and then use HOST_WIDE_INT_PRINT_HEX as format would be the gcc way.

> Index: cp/class.c
> ===================================================================
> --- cp/class.c  (Revision 193925)
> +++ cp/class.c  (Arbeitskopie)
> @@ -7817,7 +7817,7 @@ dump_class_hierarchy_r (FILE *stream,
>    indented = maybe_indent_hierarchy (stream, indent, 0);
>    fprintf (stream, "%s (0x%lx) ",
>            type_as_string (BINFO_TYPE (binfo), TFF_PLAIN_IDENTIFIER),
> -          (unsigned long) binfo);
> +          (unsigned long) (uintptr_t) binfo);
Kai Tietz - Nov. 29, 2012, 12:45 p.m.
2012/11/29 Pedro Alves <palves@redhat.com>:
> On 11/29/2012 12:03 PM, Kai Tietz wrote:
>> Hello,
>>
>> this trivial patch fixes a bootstrap issue on LLP64 hosts.
>
> But it's trivial at the expense of truncating the pointer.
> Looking around, I'd think that something like casting to hwi (after uintptr_t),
> and then use HOST_WIDE_INT_PRINT_HEX as format would be the gcc way.
>
>> Index: cp/class.c
>> ===================================================================
>> --- cp/class.c  (Revision 193925)
>> +++ cp/class.c  (Arbeitskopie)
>> @@ -7817,7 +7817,7 @@ dump_class_hierarchy_r (FILE *stream,
>>    indented = maybe_indent_hierarchy (stream, indent, 0);
>>    fprintf (stream, "%s (0x%lx) ",
>>            type_as_string (BINFO_TYPE (binfo), TFF_PLAIN_IDENTIFIER),
>> -          (unsigned long) binfo);
>> +          (unsigned long) (uintptr_t) binfo);
>
> --
> Pedro Alves

Well, hwi format is of course the way to display pointer complete.  On
the other hand are in most cases lower 32-bit sufficent on
debug-output.

Kai
Pedro Alves - Nov. 29, 2012, 12:49 p.m.
On 11/29/2012 12:45 PM, Kai Tietz wrote:
> 2012/11/29 Pedro Alves <palves@redhat.com>:
>> On 11/29/2012 12:03 PM, Kai Tietz wrote:
>>> Hello,
>>>
>>> this trivial patch fixes a bootstrap issue on LLP64 hosts.
>>
>> But it's trivial at the expense of truncating the pointer.
>> Looking around, I'd think that something like casting to hwi (after uintptr_t),
>> and then use HOST_WIDE_INT_PRINT_HEX as format would be the gcc way.
>>
>>> Index: cp/class.c
>>> ===================================================================
>>> --- cp/class.c  (Revision 193925)
>>> +++ cp/class.c  (Arbeitskopie)
>>> @@ -7817,7 +7817,7 @@ dump_class_hierarchy_r (FILE *stream,
>>>    indented = maybe_indent_hierarchy (stream, indent, 0);
>>>    fprintf (stream, "%s (0x%lx) ",
>>>            type_as_string (BINFO_TYPE (binfo), TFF_PLAIN_IDENTIFIER),
>>> -          (unsigned long) binfo);
>>> +          (unsigned long) (uintptr_t) binfo);
>>

> Well, hwi format is of course the way to display pointer complete.  On
> the other hand are in most cases lower 32-bit sufficent on
> debug-output.

But what's the point of not making it complete?  It's not like we're talking
about a large amount of work to get it right.  It should be a two-line patch?

Patch

Index: cp/class.c
===================================================================
--- cp/class.c  (Revision 193925)
+++ cp/class.c  (Arbeitskopie)
@@ -7817,7 +7817,7 @@  dump_class_hierarchy_r (FILE *stream,
   indented = maybe_indent_hierarchy (stream, indent, 0);
   fprintf (stream, "%s (0x%lx) ",
           type_as_string (BINFO_TYPE (binfo), TFF_PLAIN_IDENTIFIER),
-          (unsigned long) binfo);
+          (unsigned long) (uintptr_t) binfo);
   if (binfo != igo)
     {
       fprintf (stream, "alternative-path\n");
@@ -7842,7 +7842,7 @@  dump_class_hierarchy_r (FILE *stream,
       fprintf (stream, " primary-for %s (0x%lx)",
               type_as_string (BINFO_TYPE (BINFO_INHERITANCE_CHAIN (binfo)),
                               TFF_PLAIN_IDENTIFIER),
-              (unsigned long)BINFO_INHERITANCE_CHAIN (binfo));
+              (unsigned long) (uintptr_t) BINFO_INHERITANCE_CHAIN (binfo));
     }
   if (BINFO_LOST_PRIMARY_P (binfo))
     {
@@ -7975,7 +7975,8 @@  dump_vtable (tree t, tree binfo, tree vtable)
       if (ctor_vtbl_p)
        {
          if (!BINFO_VIRTUAL_P (binfo))
-           fprintf (stream, " (0x%lx instance)", (unsigned long)binfo);
+           fprintf (stream, " (0x%lx instance)", (unsigned long)
+                    (uintptr_t) binfo);
          fprintf (stream, " in %s", type_as_string (t, TFF_PLAIN_IDENTIFIER));
        }
       fprintf (stream, "\n");