public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: DJ Delorie <dj@redhat.com>
To: Richard Guenther <richard.guenther@gmail.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: PR 45819 - possible fix?
Date: Tue, 26 Jul 2011 15:40:00 -0000	[thread overview]
Message-ID: <201107261501.p6QF1MTH026712@greed.delorie.com> (raw)
In-Reply-To: <CAFiYyc0WnWaux73w0PVKqJz=KM5br+k29aB3hjYqQCa==uoNwg@mail.gmail.com>	(message from Richard Guenther on Tue, 26 Jul 2011 09:34:36 +0200)


> So don't lie to GCC then?  You specify
> 
> struct X { char c; int i; } __attribute__((packed)) x;
> 
> and expect that GCC knows x.i is aligned to 4 bytes!?

The actual header is much more complex than this trivial example.

It also fails with this example, where the port_status[] array *is*
obviously aligned, but the "packed" attribute *also* makes gcc think
the *structure* is misaligned, which is not the case:

struct ehci_regs {                                                              
	char x;                                                                         
	short y;                                                                         
	char z;                                                                         
	unsigned int port_status[0];                                                    
} __attribute__ ((packed));                                                     

The line that fails is the next one:

	return *(volatile unsigned int *)status_reg;                                   

The user has explicitly told gcc that the pointer is a valid
pointer-to-int.  How else can the user tell gcc it's wrong about
alignment?  I mean, without changing zillions of released kernel
header files?

> Or declare it a bug in volatile handling (which is, after all, not
> very well defined)

I've been working on "fixing" volatile to mean "do what I tell you"
but historically, "volatile" has had lots of leeway in gcc.

> and simply throw away any alignment information we have in that case
> (which would make it an expander bug I guess, unless the arm target does
> something special here).

Various targets choose to honor volatile over gcc's natural bitfield
access rules, and yes, we're doing it in the expander.  Other volatile
access rules could be applied there too.

      reply	other threads:[~2011-07-26 15:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-21  6:51 DJ Delorie
2011-07-21  9:53 ` Richard Guenther
2011-07-21 17:36   ` DJ Delorie
2011-07-22  9:13     ` Richard Guenther
2011-07-22 10:32       ` Richard Guenther
2011-07-23  9:21         ` DJ Delorie
2011-07-23  9:38         ` DJ Delorie
2011-07-23 12:58           ` Richard Guenther
2011-07-24  4:40             ` DJ Delorie
2011-07-24 12:46               ` Richard Guenther
2011-07-25 17:24                 ` DJ Delorie
2011-07-26  8:28                   ` Richard Guenther
2011-07-26 15:40                     ` DJ Delorie [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=201107261501.p6QF1MTH026712@greed.delorie.com \
    --to=dj@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    /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).