This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

Re: gcc.c-torture/execute/pr22098-1.c


On Tue, Nov 18, 2008 at 06:32:56PM -0500, DJ Delorie wrote:
> 
> Like this?  (a bigger size_t is OK for this test)
> 
> extern void abort (void);
> extern void exit (int);
> typedef __SIZE_TYPE__ size_t;
> int
> main (void)
> {
>   int a = 0;
>   int *p;
>   size_t b;
>   if (sizeof (size_t) < sizeof (int *))
>     exit (0);
>   b = (size_t)(p = &(int []){0, 1, 2}[++a]);
>   if (a != 1 || *p != 1 || *(int *)b != 1)
>     abort ();
>   exit (0);
> }

Yes.

>From a standards point of view, I don't think you could ever have sizeof
(size_t) being larger than sizeof (void *).  But it is ok if some port
somewhere makes size_t larger than a point.

-- 
Michael Meissner, IBM
4 Technology Place Drive, MS 2203A, Westford, MA, 01886, USA
meissner@linux.vnet.ibm.com


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