public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paul Koning <pkoning@equallogic.com>
To: dave.korn@artimi.com
Cc: sjackman@gmail.com, gcc@sources.redhat.com
Subject: RE: memcpy to an unaligned address
Date: Tue, 02 Aug 2005 19:48:00 -0000	[thread overview]
Message-ID: <17135.52757.353000.216332@gargle.gargle.HOWL> (raw)
In-Reply-To: <SERRANObDBRArVc4Iu1000000e0@SERRANO.CAM.ARTIMI.COM>

>>>>> "Dave" == Dave Korn <dave.korn@artimi.com> writes:

 Dave> ----Original Message----
 >> From: Shaun Jackman Sent: 02 August 2005 20:26

 >> On 8/2/05, Paul Koning <pkoning@equallogic.com> wrote:
 >>> One of the things that continues to baffle me (and my colleagues)
 >>> is the bizarre way in which attributes such as "packed" work when
 >>> applied to structs.
 >>> 
 >>> It would be natural to assume, as Shaun did, that marking a
 >>> struct "packed" (or, for that matter, "packed,aligned(2)") would
 >>> apply that attribute to the fields of the struct.
 >>  This is exactly the behaviour suggested by the info docs:
 >> 
 >> $ info gcc 'C Ext' 'Type Attr' ...  Specifying this attribute for
 >> `struct' and `union' types is equivalent to specifying the
 >> `packed' attribute on each of the structure or union members.
 >> 


 Dave> There are two separate issues here:

 Dave> 1) Is the base of the struct aligned to the natural alignment,
 Dave> or can the struct be based at any address

 Dave> 2) Is there padding between the struct members to maintain
 Dave> their natural alignments (on the assumption that the struct's
 Dave> base address is aligned.)

Sure.  But in Shaun's case it looks like (2) has been applied, except
that the compiler doesn't adjust the generated code correctly.  I
would argue that "packed" applied to a whole struct should produce
BOTH effects 1 and 2.

There's a third case for which there appears to be no notation:

3) A pointer to a T that doesn't have the normal alignment of 
   the type T.

For example, as far as I can tell, GCC offers no way to say "pointer
to unaligned int" -- short of creating a one-member struct.

   paul

  reply	other threads:[~2005-08-02 19:48 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-02 17:32 Shaun Jackman
2005-08-02 17:43 ` Dave Korn
2005-08-02 19:13   ` Shaun Jackman
2005-08-02 19:19     ` Paul Koning
2005-08-02 19:26       ` Shaun Jackman
2005-08-02 19:40         ` Dave Korn
2005-08-02 19:48           ` Paul Koning [this message]
2005-08-02 20:15           ` Shaun Jackman
2005-08-02 20:29             ` Paul Koning
2005-08-02 20:29             ` Mike Stump
2005-08-02 20:38               ` Andrew Pinski
2005-08-02 20:45                 ` Ian Lance Taylor
2005-08-02 21:30                   ` Mike Stump
2005-08-02 21:34                     ` Joe Buck
2005-08-03 18:00                   ` Richard Henderson
2005-08-03 18:15                     ` Shaun Jackman
2005-08-03 18:19                       ` Dave Korn
2005-08-03 21:26                       ` Richard Henderson
2005-08-04  4:42                     ` Ian Lance Taylor
2005-08-04 12:40                     ` Paul Koning
2005-08-02 20:46                 ` Paul Koning
2005-08-02 22:17                   ` Shaun Jackman
2005-08-03 17:16                     ` Paul Koning
2005-08-02 22:26                   ` Shaun Jackman
2005-08-02 22:29                     ` Shaun Jackman
2005-08-02 21:05                 ` Mike Stump
2005-08-02 21:11                   ` Joe Buck
2005-08-02 22:15                     ` Shaun Jackman
2005-08-02 22:12                       ` Joe Buck
2005-08-02 17:48 ` Falk Hueffner
2005-08-02 18:03 ` Mike Stump
     [not found] <345be691050804025955c0b4ab@mail.gmail.com>
2005-08-04 15:06 ` Shaun Jackman
2005-08-04 15:09   ` Christian Joensson
2005-08-05  8:41   ` Carl Whitwell
2005-08-05 16:09     ` Shaun Jackman

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=17135.52757.353000.216332@gargle.gargle.HOWL \
    --to=pkoning@equallogic.com \
    --cc=dave.korn@artimi.com \
    --cc=gcc@sources.redhat.com \
    --cc=sjackman@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).