Re: sizeof on arrays and pointers
From: BRG (brg_at_nowhere.org)
Date: 01/20/05
- Next message: William DePalo [MVP VC++]: "Re: Comctl32.dll"
- Previous message: JoeZ: "Comctl32.dll"
- In reply to: Doug Harrison [MVP]: "Re: sizeof on arrays and pointers"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 20 Jan 2005 15:22:28 +0000
Doug Harrison [MVP] wrote:
> BRG wrote:
>
>>The following program produces different results on the five different
>>compilers I am using:
>>
>>---------------------------------
>>#include <stdio.h>
>>typedef char ctype[100];
>>int main()
>>{ char x[100], *y;
>> ctype c;
>> printf("\n%3ld %3ld", sizeof(x), sizeof(&x));
>> printf("\n%3ld %3ld", sizeof(y), sizeof(&y));
>> printf("\n%3ld %3ld", sizeof(c), sizeof(&c));
>> return 0;
>>}
>>---------------------------------
>>
>>These results are as follows:
>>
>>Compiler 1 Compiler 2 Compiler 3 Compiler 4 Compiler 5
>>100 100 100 100 100 4 100 2 100 100
>> 4 4 4 4 4 4 2 2 4 4
>>100 100 100 100 100 4 100 2 100 100
>>
>>VC++ produces the first of these and is claimed to be wrong by some who
>>think that the right answer is number three.
>>
>>Is this a bug in VC++?
Reported as a bug in VC8 (beta) and accepted for a fix in future
versions as it is already to late for VC8
Brian Gladman
- Next message: William DePalo [MVP VC++]: "Re: Comctl32.dll"
- Previous message: JoeZ: "Comctl32.dll"
- In reply to: Doug Harrison [MVP]: "Re: sizeof on arrays and pointers"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|