This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/13321] New: sizeof of an array argument will always return 4
- From: "Stefani at Seibold dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Dec 2003 20:36:26 -0000
- Subject: [Bug c/13321] New: sizeof of an array argument will always return 4
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
A sizeof of an array passed to a function with an array argument will return
always return the wrong value 4.
For example:
#include <stdio.h>
void func(char x[10])
{
printf("sizeof(x)=%d\n",sizeof(x));
}
int main(void)
{
func("012345678");
return 0;
}
The output of this program is: 4
and not as expected: 10
I know that an array will be passed as a pointer, so i think the sizeof will
return the size of this pointer and not the size of the declared argument.
The same problem occurs also in gnu c++.
--
Summary: sizeof of an array argument will always return 4
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Stefani at Seibold dot net
CC: Stefani at Seibold dot net,gcc-bugs at gcc dot gnu dot
org
GCC build triplet: i586-linux-gcc
GCC host triplet: i586-linux-gcc
GCC target triplet: i586-linux-gcc
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13321