From: SourceForge.net <no...@so...> - 2008-06-01 11:59:39
|
Bugs item #1981238, was opened at 2008-06-01 12:00 Message generated for change (Comment added) made by bortel You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1981238&group_id=599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Laszlo BORTEL (bortel) Assigned to: Nobody/Anonymous (nobody) Summary: Size of structure with zero length bitfield is incorrect Initial Comment: The following code correctly produces a one-byte-size structure in code memory, because the zero length bitfield p.a occupies no memory. The problem is that sizeof(p) incorrectly reports that the size of the structure is 2 bytes! code struct { char a:0; char b; } p ={1, 2}; int main (void) { return sizeof(p); } Command to compile: C:\>sdcc BugReport19.c C:\>sdcc -v SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.8.1 #5 187 (May 31 2008) (MINGW32) (My reason of using the normally useless zero length bitfield is to temporarily "hide" a field for development/debugging purposes, without deleting or commenting out one-by-one all the initialiser values of the structure array.) ---------------------------------------------------------------------- >Comment By: Laszlo BORTEL (bortel) Date: 2008-06-01 13:59 Message: Logged In: YES user_id=1063737 Originator: YES Please consider implementing the closely related optimization request "[ 1856455 ] zero length bitfield starts new byte allocation" when fixing this bug. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1981238&group_id=599 |