From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 1375 invoked from network); 9 Mar 1998 23:30:55 -0000 Received: from ellpspace.math.ualberta.ca (michal@129.128.88.19) by mail2.redhat.com with SMTP; 9 Mar 1998 23:30:55 -0000 Received: (from michal@localhost) by ellpspace.math.ualberta.ca (8.8.5/8.8.5) id QAA11122 for axp-list@redhat.com; Mon, 9 Mar 1998 16:31:13 -0700 From: Michal Jaegermann Message-Id: <199803092331.QAA11122@ellpspace.math.ualberta.ca> Subject: Re: Whereis libm.a ? To: axp-list@redhat.com Date: Mon, 9 Mar 1998 16:31:12 -0700 (MST) In-Reply-To: from "Christopher Curtis" at Mar 9, 98 03:52:59 pm Content-Type: text Christopher Curtis writes: > > Why does this program: > > #line 3823 "configure" > #include "confdefs.h" > #include > main() > { > FILE *f=fopen("conftestval", "w"); > if (!f) exit(1); > fprintf(f, "%d\n", sizeof(char)); > exit(0); > } > > tell me that the sizeof(char) is 0 ? Because it is buggy. C standard says that type returned by sizeof() operator is of an unsigned integral type and is implementation defined ("integral type" does not mean, of course, 'int'). But it also says that when sizeof is applied to any object of structure, union or array then the result gives a total number of bytes in such object, including any internal padding if present. On 64-bit Alpha this requirement obviously makes a choice of 'unsigned int' for a type of value of sizeof operator unfeasible. On 32-bit machines sizeof(sizeof_t) happens to be the same as sizeof(int) and the code above does accidentally what you expect. If you would use -Wall to a compiler gcc would tell you loud and clear what it thinks about this code. Michal