Search

sizeof error on pointers to arrays by BRG

Closed
as Fixed Help for as Fixed

4
Sign in to vote
0
Sign in to vote
Sign in
to vote
Type: Bug
ID: 101702
Opened: 1/17/2005 8:18:20 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
sizeof(&x) gives the wrong result when x is an array

this is also present in previous versions of VC++
Details (expand)
Product Language
English
Version
Visual C++ 2005 Express Beta 1
Category
Language/Compiler
Operating System
Windows XP Professional
Operating System Language
English
Steps to Reproduce
compile and run:

#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));
printf("\n\n");
return 0;
}
Actual Results
100 100
4 4
100 100
Expected Results
100 4
4 4
100 4

(according to the language police who I have raised this with)
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 1/17/2005 at 11:28 AM
Thank you for submitting this to us. We will investigate and keep you informed.
Visual C++ Team
Posted by Microsoft on 1/17/2005 at 4:38 PM
Thank you for your report. We would like to fix this, but unfortunately it is too late in this product cycle.
Alvin Chardon
Visual C++ Compiler
Posted by Microsoft on 10/24/2005 at 6:06 PM
This issue has been reactivated as we begin planning for the next version of Visual Studio. Over the coming months we will reconsider feedback that was previously postponed. We welcome your comments and participation in this process.

-- Visual Studio Team
Posted by Microsoft on 1/20/2006 at 3:58 PM
The Microsoft Sub-status is now "Working on solution"
Posted by Microsoft on 1/25/2006 at 2:22 PM
The Microsoft Sub-status is now "Working on solution"
Posted by Microsoft on 1/26/2006 at 12:38 PM
Thank you for reporting this issue. It is fixed in the internal build of the compiler.

Keiji Oenoki
Visual C++ Compiler
Posted by Microsoft on 1/17/2007 at 1:44 AM
Thank you for submitting this issue. The bug has been resolved Fixed, and its resolution shipped as part of Visual Studio 2005 Service Pack 1 (SP1).

You can download SP1 at http://msdn.microsoft.com/vstudio/support/vs2005sp1/default.aspx. If installing SP1 does not resolve the issue for you, please reactivate.

Thanks again for your feedback!
-Scott Currie
-DDTFA Program Manager