This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Structure Return Testcase


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

-- 
Joseph S. Myers
jsm28@cam.ac.uk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]