On Wednesday 07 February 2007 10:41 am, Phil Endecott wr
> Err, maybe my example was over-simplified then, sorry.  Try another 
> level of indirection:
> 
> void inc(int* i) {
>    (*i)++;
> }
> 
> void f(struct S* s) {
>    inc(&(s->intfield);

One would expect that to generate a warning ... that you're
discarding the "packed" attribute on that value.

I can understand that such errors can cascade rudely through
software, such that the GCC team doesn't want to make that be
any kind of error (without "-Werr").


> }
> 
> 
> Please look in the gcc-help archives for December and search for my 
> name; you'll find a long thread where I slowly come to understand how 
> this works (or rather how it doesn't work and how it doesn't warn you 
> that it's not going to work).  I believe that the people that I was 
> corresponding with know what they are talking about.  In particular, 
> here's a quote from Paul Brook 
> (http://gcc.gnu.org/ml/gcc-help/2006-12/msg00115.html):
> 
>    " the compiler is allowed to assume that the low 2 bits of an int* 
> are zero. "

Unless it's declared as packed ... a fact which is 100% clear in the
definition of "packed".

I find it instructive that Paul never responded to your followup,
or several pointed questions where you identified issues.  That
particular thread seemed inconclusive to me, as if maybe Paul didn't
want to acknowledge the bug you found.  (I think we've all seen such
behavior from other developers.  Maybe from ourselves, too!)

My two cents:  the MINIMAL fix to GCC is to emit a warning when
passing a pointer-to-packed discards packed-ness that affects
the pointer alignment guarantee.  And I suspect that should be a
"warn always", since the whole point of using that attribute on
e.g. an "int" (and int-member-of-struct) is to ensure the compiler
will stop making the specific assumption that's being discarded ...

- Dave


-------------------------------------------------------------------------
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