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]

Structure Return Testcase




I've been talking with Mark Mitchell about execute/20010124-1.c and we believe
this test is invalid according to C/C++ standards.

If we look at the two statements that are producing structure returns
which trigger the overlapping memcpy we have:

    union U u;
    u.b.s = f(&u.a.s);
    u.a.s = f(&u.b.s);


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.

Do you concur?  Is there some other reason we need to keep that test?

[ FWIW, this is the last regression for the PA against gcc-2.95.2 in the
  c-torture execution tests :-) ]

jeff


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