memcpy / Language Lawyer / optimization question

Joe Buck Joe.Buck@synopsys.COM
Thu Dec 9 23:53:00 GMT 2004


On Thu, Dec 09, 2004 at 05:54:08PM -0500, Paul Schlie wrote:
> As a more general but related question: as C does not define/specify
> everything, and even occasionally specifies something as being explicitly
> "unspecified", giving license to the complier to express whatever incidental
> behavior it may have; has the GCC team adopted the strategy that it will
> strive to adopt and document the behavior which seems most generally useful
> and/or least-fragile in such circumstances ... ?

No, because such a design decision would lead to a compiler that produces
extremely slow code.  Some programmer might accidentally try to use
unaligned integers on a processor that does not support unaligned word
accesses, so your dictum would force the compiler to do all memory
accesses one byte at a time, just so that this hypothetical programmer can
continue to write sloppy code.

If, as a programmer, you follow the language standard, the gcc team will
immediately accept that any failure to handle your code is a gcc bug.
Same goes for use of a documented extension in a documented way.  Do
otherwise, and you are on your own.




More information about the Gcc mailing list