This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

sizeof bug


/*
This is some weird interaction between typedef, sizeof, and argument
passing.  I would expect all the sizeofs to return 16, but mysteriously
it returns 4 in one case.

GCC version: gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2
release)
OS: Linux 2.2.5-15 (Redhat 6.0)
Hardware: Intel Pentium II
*/

#include <stdio.h>

typedef unsigned char ArrayType[16];

void foo(ArrayType arrayInstance)
{
    printf("In foo, sizeof(arrayInstance) = %d, sizeof(ArrayType) =
%d\n",
        sizeof(arrayInstance), sizeof(ArrayType));
}

int
main(int argc, char *argv[])
{
    ArrayType arrayInstance;

    printf("In main, sizeof(arrayInstance) = %d, sizeof(ArrayType) =
%d\n",
        sizeof(arrayInstance), sizeof(ArrayType));
    foo(arrayInstance);
}

S/MIME Cryptographic Signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]