Type of expression sizeof(x)
D. Jason Penney
penneyj at servio.UUCP
Wed Sep 20 07:28:06 AEST 1989
Consider the following simple program?
#include <stdio.h>
main()
{
if (3 - sizeof(long) < 0)
printf("passed\n");
else
printf("failed\n");
}
On our DECStation-3100 running Ultrix, this program returns "failed" instead
of "passed". It seems that the sizeof() is promoting the expression to be
unsigned. By the way, changing 3 to 3L does NOT make the problem disappear.
I am posting this quirk to comp.lang.c because I would be VERY interested to
hear (by e-mail, please) from anyone who thinks that this is acceptable
behavior.
I am posting this to comp.unix.ultrix because I think you poor implementors
ought to be forewarned.
Our conversation with DEC re this bug was extremely unhelpful. They claim that
the return type of a sizeof() expression is system-dependent.
--
D. Jason Penney Ph: (503) 629-8383
Beaverton, OR 97006 uucp: ...uunet!servio!penneyj
STANDARD DISCLAIMER: Should I or my opinions be caught or killed, the
company will disavow any knowledge of my actions...
More information about the Comp.unix.ultrix
mailing list