public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Jonas Pfeil" <jonas.pfeil@uni-ulm.de>
To: "'Segher Boessenkool'" <segher@kernel.crashing.org>,
	       "'Jeff Law'" <law@redhat.com>
Cc: <gcc-patches@gcc.gnu.org>
Subject: BUMP: AW: [PATCH] Microblaze: Type confusion in fprintf
Date: Fri, 04 Oct 2019 08:14:00 -0000	[thread overview]
Message-ID: <0ded01d57a8b$c6709f10$5351dd30$@uni-ulm.de> (raw)

Yes, it is a 32-bit host and 32-bit target.
HOST_WIDE_INT is long long (on ARM).
Also it says 4 lines above that the type of value_long is unsigned long, so
lets use the specifier for unsigned long.

Jonas

-----Ursprüngliche Nachricht-----
Von: Segher Boessenkool <segher@kernel.crashing.org> 
Gesendet: Sonntag, 22. September 2019 02:52
An: Jeff Law <law@redhat.com>
Cc: Jonas Pfeil <jonas.pfeil@uni-ulm.de>; gcc-patches@gcc.gnu.org
Betreff: Re: [PATCH] Microblaze: Type confusion in fprintf

On Fri, Sep 20, 2019 at 04:50:12PM -0600, Jeff Law wrote:
> On 9/12/19 7:33 AM, Jonas Pfeil wrote:
> > A type confusion leads to illegal (and nonsensical) assembly on 
> > certain host architectures (e.g. ARM), where HOST_WIDE_INT (64 bit) 
> > and unsigned long (32
> > bit) have different alignments. So this has printed an uninitialized 
> > register instead of the intended value. This fixes float constant 
> > initialization on an ARM->Microblaze cross compiler.
> > 
> > --- a/gcc/config/microblaze/microblaze.c
> > +++ b/gcc/config/microblaze/microblaze.c
> > @@ -2468,7 +2468,7 @@ print_operand (FILE * file, rtx op, int letter)
> >           unsigned long value_long;
> >           REAL_VALUE_TO_TARGET_SINGLE (*CONST_DOUBLE_REAL_VALUE (op),
> >                                        value_long);
> > -         fprintf (file, HOST_WIDE_INT_PRINT_HEX, value_long);
> > +         fprintf (file, "%#lx", value_long);
> >         }
> >        else
> >         {
> > 
> But shouldn't HOST_WIDE_INT_PRINT_HEX here result in the same thing?
> 
> >From hwint.h:
> 
> #ifndef HAVE_INTTYPES_H
> #if INT64_T_IS_LONG
> # define GCC_PRI64 HOST_LONG_FORMAT
> #else
> # define GCC_PRI64 HOST_LONG_LONG_FORMAT #endif
> 
> [ ... ]
> 
> #undef PRIx64
> #define PRIx64 GCC_PRI64 "x"
> [ ... ]
> 
> #define HOST_WIDE_INT_PRINT_HEX "%#" PRIx64
> 
> 
> If that's not giving us back %#lx, then it seems to me like something 
> is wrong elsewhere.

This is a 32-bit target though, so INT64_T_IS_LONG is false.


Segher

                 reply	other threads:[~2019-10-04  8:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='0ded01d57a8b$c6709f10$5351dd30$@uni-ulm.de' \
    --to=jonas.pfeil@uni-ulm.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    --cc=segher@kernel.crashing.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).