This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Remove testsuite/gcc.c-torture/execute/20000603-1.c
- From: "Joseph S. Myers" <jsm at polyomino dot org dot uk>
- To: Diego Novillo <dnovillo at redhat dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 5 Feb 2004 22:35:15 +0000 (UTC)
- Subject: Re: Remove testsuite/gcc.c-torture/execute/20000603-1.c
- References: <1076019618.17914.8.camel@localhost.localdomain>
On Thu, 5 Feb 2004, Diego Novillo wrote:
> Today it bit me again and I think the testcase is wrong. Jason agrees
> and tells me that this is mentioned in C99 6.5p7
Suppose a union is defined between struct s1 and struct s2, and is used in
main rather than a pointer cast. Does it then work? (See DR#236 and the
references from there; there is as yet no precise consensus on the rules,
but it appears the union should at least be visible at the point of use.)
Though you still have the fundamental problem of whether the relevant
objects are *a and *b (different types) or a->d and b->d (same type), it
should work given the union, and any DR resolutions can have new testcases
derived from it rather than guessing what might be relevant.
> - struct s1 { double d; };
> - struct s2 { double d; };
union u { struct s1 x; struct s2 y; };
> - double f(struct s1 *a, struct s2 *b)
> - {
> - a->d = 1.0;
> - return b->d + 1.0;
> - }
> -
> - int main()
> - {
> - struct s1 a;
> - a.d = 0.0;
> - if (f (&a, (struct s2 *)&a) != 2.0)
change to
union u a;
a.x.d = 0.0;
if (f (&a.x, &a.y) != 2.0)
> - abort ();
> - return 0;
> - }
--
Joseph S. Myers
jsm@polyomino.org.uk