From: SourceForge.net <no...@so...> - 2003-07-13 22:24:11
|
Bugs item #770484, was opened at 2003-07-13 03:56 Message generated for change (Comment added) made by nobody You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=770484&group_id=599 Category: C-Front End Group: None Status: Open Resolution: None Priority: 5 Submitted By: Scott Bronson (bronson) Assigned to: Nobody/Anonymous (nobody) Summary: sizeof() on struct containing an array is wrong Initial Comment: With this program: --------- typedef struct { unsigned char length; unsigned char unicode_data[]; } StringDescriptor; StringDescriptor sd = { sizeof(sd), { 'a', 0, 'b', 0, 'c', 0 } }; unsigned char d = sizeof(sd); ----------- sizeof(sd) should be 7, but sdcc thinks it's 1. Both the 8051 and Z80 code generation show problems with this input, but they produce different output. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2003-07-13 15:24 Message: Logged In: NO This is invalid code. The compiler shouldn't accept it. [tim@pauli /home/tim]$ cat test.c typedef struct { unsigned char length; unsigned char unicode_data[]; } StringDescriptor; [tim@pauli /home/tim]$ gcc -c -Wall -W -ansi -pedantic test.c test.c:3: array size missing in `unicode_data' [tim@pauli /home/tim]$ ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=770484&group_id=599 |