This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: memcpy / Language Lawyer / optimization question
- From: Joe Buck <Joe dot Buck at synopsys dot COM>
- To: Paul Schlie <schlie at comcast dot net>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 9 Dec 2004 15:53:39 -0800
- Subject: Re: memcpy / Language Lawyer / optimization question
- References: <BDDE41C0.82F2%schlie@comcast.net>
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.