public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Non-portable test?
@ 2009-09-23  8:44 Yuri Gribov
  2009-09-23  8:57 ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Yuri Gribov @ 2009-09-23  8:44 UTC (permalink / raw)
  To: gcc

Hi all,

This is my first post to the list so do not be too harsh)

I have expected all c-torture tests to be highly portable but I have
recently ran into test which relies on int being 32-bit
(execute/980526-2.c).

The test runs to_kdev_t(0x12345678) (see below) and verifies that
result equals 0x15800078. But this is true only with 32-bit ints. With
64-bits we have 0x48d15800078.

static inline kdev_t to_kdev_t(int dev)
{
   int major, minor;

   if (sizeof(kdev_t) == 16)
       return (kdev_t)dev;
   major = (dev >> 8);
   minor = (dev & 0xff);
   return ((( major ) << 22 ) | (  minor )) ;
}

Shouldn't we modify a precondition in main:
   if (sizeof (int) < 4)
     exit (0);
to be
   if (sizeof (int) != 4)
     exit (0);
or better
   if( sizeof(int)*CHAR_BIT != 32 )
     exit(0)
?

Best regards,
Yuri

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Non-portable test?
  2009-09-23  8:44 Non-portable test? Yuri Gribov
@ 2009-09-23  8:57 ` Paolo Bonzini
  2009-09-23  9:22   ` Yuri Gribov
       [not found]   ` <323ac04e0909230221x2c256d2bmf98d348c1c578e3a@mail.gmail.com>
  0 siblings, 2 replies; 4+ messages in thread
From: Paolo Bonzini @ 2009-09-23  8:57 UTC (permalink / raw)
  To: Yuri Gribov; +Cc: gcc

On 09/23/2009 10:44 AM, Yuri Gribov wrote:
> Hi all,
>
> This is my first post to the list so do not be too harsh)
>
> I have expected all c-torture tests to be highly portable but I have
> recently ran into test which relies on int being 32-bit
> (execute/980526-2.c).

Yes, it's possible that 64-bit ints are not supported by the testsuite. 
  Changes to fix that are welcome.

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Non-portable test?
  2009-09-23  8:57 ` Paolo Bonzini
@ 2009-09-23  9:22   ` Yuri Gribov
       [not found]   ` <323ac04e0909230221x2c256d2bmf98d348c1c578e3a@mail.gmail.com>
  1 sibling, 0 replies; 4+ messages in thread
From: Yuri Gribov @ 2009-09-23  9:22 UTC (permalink / raw)
  To: gcc

[-- Attachment #1: Type: text/plain, Size: 256 bytes --]

> Yes, it's possible that 64-bit ints are not supported by the testsuite.
>  Changes to fix that are welcome.

I am not a gcc developer. Could someone verify and commit this patch
for testsuite/gcc.c-torture/execute/980526-2.c?

Best regards,
Yuri

[-- Attachment #2: 980526-2.patch --]
[-- Type: application/octet-stream, Size: 411 bytes --]

--- ../Download/trunk/gcc/testsuite/gcc.c-torture/execute/980526-2.c	2009-09-23 12:07:09.000000000 +0400
+++ 980526-2.c	2009-09-23 12:10:32.000000000 +0400
@@ -1,3 +1,5 @@
+#include <limits.h>
+
 typedef unsigned int dev_t;
 typedef unsigned int kdev_t;
 
@@ -50,7 +52,7 @@
 
 int main(void)
 {
-	if (sizeof (int) < 4)
+	if (sizeof (int)*CHAR_BIT != 32)
 	  exit (0);
 
 	return sys_mknod("test",1,0x12345678);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Non-portable test?
       [not found]     ` <4AB9E926.8080404@gnu.org>
@ 2009-09-23  9:25       ` Yuri Gribov
  0 siblings, 0 replies; 4+ messages in thread
From: Yuri Gribov @ 2009-09-23  9:25 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: gcc

> Done.  But if you have more cases, please report them.
Not yet. Thx!

-- 
Best regards,
Yuri

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-09-23  9:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-23  8:44 Non-portable test? Yuri Gribov
2009-09-23  8:57 ` Paolo Bonzini
2009-09-23  9:22   ` Yuri Gribov
     [not found]   ` <323ac04e0909230221x2c256d2bmf98d348c1c578e3a@mail.gmail.com>
     [not found]     ` <4AB9E926.8080404@gnu.org>
2009-09-23  9:25       ` Yuri Gribov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).