On Fri, Sep 30, 2011 at 4:43 PM, Jakub Jelinek <ja...@redhat.com> wrote: > On Fri, Sep 30, 2011 at 05:36:47PM +0200, Georg-Johann Lay wrote: >> >> The target has >> >> >> >> 2 = sizeof (short) >> >> 2 = sizeof (int) >> >> 4 = sizeof (long int) >> >> 8 = sizeof (long long int) >> >> >> >> Could you fix that? I.e. parametrize sizeof(int) out or skip the test by >> >> means of >> >> >> >> /* { dg-require-effective-target int32plus } */ >> >> >> >> or similar. >> >> >> >> Thanks, Johann >> >> >> >> [...] >> >> >> > The problem actually happens when we compare float vector with float >> > vector, it is assumed that we should get int vector as a result, but >> > it turns out that we are getting long int. >> > >> > The same with double, we assume that sizeof (double) == sizeof (long >> > long). But as it seems double has the same size as float. >> >> Yes. >> >> sizeof(double) = sizeof(float) = 4 >> >> > Hm, I can put conditional of sort: >> > if (sizeof (doulbe) == sizeof (long long)) and others. Or may be there >> > is more elegant way of solving this? >> >> That's too late because this won't prevent the compiler from error. >> The error already happens at compile time, not at run time. > > Isn't it possible to do something like: > vector (4, float) f0; > vector (4, float) f1; > - vector (4, int) ifres; > + vector (4, __typeof (f0 > f1)) ifres; > > f0 = (vector (4, float)){(float)argc, 1., 2., 10.}; > f1 = (vector (4, float)){0., 3., 2., (float)-23}; > test (4, f0, f1, ifres, "%f"); > > /* Double comparison. */ > vector (2, double) d0; > vector (2, double) d1; > - vector (2, long long) idres; > + vector (2, __typeof (d0 > d1)) idres; > > d0 = (vector (2, double)){(double)argc, 10.}; > d1 = (vector (2, double)){0., (double)-23}; > test (2, d0, d1, idres, "%f"); > > Jakub >
Most likely we can. The question is what do we really want to check with this test. My intention was to check that a programmer can statically get correspondence of the types, in a sense that sizeof (float) == sizeof (int) and sizeof (double) == sizeof (long long). As it seems my original assumption does not hold. Before using __typeof, I would try to make sure that there is no other way to determine these correspondences. Artem.