This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Structure Return Testcase
- To: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Subject: Re: Structure Return Testcase
- From: Jeffrey A Law <law at redhat dot com>
- Date: Thu, 15 Mar 2001 12:26:57 -0700
- cc: rth at redhat dot com, gcc at gcc dot gnu dot org
- Reply-To: law at redhat dot com
In message <Pine.LNX.4.32.0103151901200.20427-100000@kern.srcf.societies.cam.
ac.uk>you write:
> On Thu, 15 Mar 2001, Jeffrey A Law wrote:
>
> > According to the C standard (thanks Mark):
> >
> > If the value being stored in an object is accessed from another
> > object that overlaps in any way the storage of the first object,
> > then the overlap shall be exact and the two objects shall have
> > qualified or unqualified versions of a compatible type; otherwise,
> > the behavior is undefined.
> >
> >
> > Given the definition of U we don't have an exact overlap between the lhs
> and
> > rhs which violates the rule above, thus triggering undefined behavior.
>
> As I've previously noted, this is essentially the testcase of DR#001, the
> example added to 6.6.6.4 of the old standard by TC1, and the example of
> 6.8.6.4 paragraph 4 in C99. Footnote 135 seems quite clear. "The return
> statement is not an assignment. The overlap restriction of subclause
> 6.5.16.1 does not apply to the case of function return."
OK. Ouch. This likely means we're going to end up doing double copies for
most/all structure returns or using memmove which isn't too efficient either.
Sigh.
jeff