On Thu, 8 Feb 2007, Phil Endecott wrote:

> Alan Stern wrote:
> > On Thu, 8 Feb 2007, Phil Endecott wrote:
> >> > From a
> >> > higher-level (source code) point of view, the alignment doesn't affect 
> >> > the 
> >> > set of operations which can be applied to the data type.
> >> 
> >> It affects whether you can legally use & to take its address.
> >
> > Are you sure about that?  I would think that if you take the address of an
> > unaligned quantity, you simply end up with an unaligned pointer, not with
> > a compiler error.  (Remember, we're talking specifically about GCC here.  
> > The official C language doesn't include any of these concepts.)
> 
> I'm not personally sure, but I'm repeating what I was told by the gcc 
> people when I asked.  Search for my name in gcc-help in December 2006.  
> I'm probably mis-remembering some of the details.  See e.g.
> 
> http://thread.gmane.org/gmane.comp.gcc.help/17551/focus=17554
> 
> In that message, I assert that it is unsafe "on some architectures" to 
> take the address of an unaligned packed structure member, and am told 
> that it is unsafe on *all* architectures because the compiler is 
> allowed by the C standard to assume that the least significant bits of 
> an int* are zero.

I can agree with this.  But above you said it wasn't _legal_ to take the 
address of an unaligned quantity.  That's very different from being 
_unsafe_.

You have to watch out when talking about computer languages, especially 
when compiler writers get involved.  The language lawyers will get you 
every time...

Alan Stern


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to