All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Mosberger <davidm@hpl.hp.com>
To: linux-ia64@vger.kernel.org
Subject: Re: [Linux-ia64] gcc bug
Date: Sat, 27 Jan 2001 05:21:30 +0000	[thread overview]
Message-ID: <marc-linux-ia64-105590693005108@msgid-missing> (raw)
In-Reply-To: <marc-linux-ia64-105590693005105@msgid-missing>

>>>>> On Fri, 26 Jan 2001 20:20:31 -0800, Jim Wilson <wilson@cygnus.com> said:

  Jim> There was a comment about non-int bitfields.  This isn't
  Jim> allowed by the ISO C standard, but it is a very common
  Jim> extension.  Most C compilers support it.  Gcc will give a
  Jim> warning about this construct if you use -pedantic.  This isn't
  Jim> related to the problem though.

Yes.

  Jim> The problem with the code is that it uses invalid casts.

Oh, you are right.

  Jim> Gcc does support type punning via unions, though the ISO C
  Jim> standard technically does not allow this.

Good.

  Jim>If you write the code like this it should work
  Jim>union g {
  Jim>  struct f f;
  Jim>  unsigned long l;
  Jim>};

  Jim>  ((union g*)&w)->f.lo = ((union g*)&value1)->f.lo;
  Jim>  ((union g*)&w)->f.hi = ((union g*)&value2)->f.hi;

OK, that seems to take care of the problem.

  Jim> However, this is a bit cryptic.  It would be clearer, and you
  Jim> will get much more efficient code, if you write it something
  Jim> like this.  Using & usually forces values onto the stack.  If
  Jim> we do it this way, we do everything in registers until the
  Jim> write to r.

Yes, that would be much cleaner and better for performance.
Unfortunately, it's not my code and it's a large and complex program,
so I'll probably have to make do with the "union" wrapper for now.

Thanks a lot,

	--david


      parent reply	other threads:[~2001-01-27  5:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-26  8:09 [Linux-ia64] gcc bug David Mosberger
2001-01-26  9:40 ` Keith Owens
2001-01-27  4:20 ` Jim Wilson
2001-01-27  5:21 ` David Mosberger [this message]

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=marc-linux-ia64-105590693005108@msgid-missing \
    --to=davidm@hpl.hp.com \
    --cc=linux-ia64@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.