From: SourceForge.net <no...@so...> - 2008-04-02 18:20:58
|
Bugs item #1932509, was opened at 2008-04-02 20:20 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1932509&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: C-Front End Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Robert Larice (rlar) Assigned to: Nobody/Anonymous (nobody) Summary: broken offsetof() handling in SDCCast.c Initial Comment: struct st { char a; }; char * buggy(){ return &(((struct st code *) 0x1234) -> a); } returns an incorrect generic pointer at least for mcs51 target. the problem is caused by a special handling of cast's resembling the above one, in file SDCCast.c:3961 this special handling was built-in to process the the following macro (comment from SDCCast.c) /* handle offsetof macro: */ /* #define offsetof(TYPE, MEMBER) \ */ /* ((unsigned) &((TYPE *)0)->MEMBER) */ which in my opinion is naive anyway. offsets are better calculated by substraction of pointers, something very remotly like: #define offsetof(TYPE, MEMBER) \ (((int) &((TYPE*)0)->MEMBER) - (int) &(TYPE*)0) i've attached a testcase for support/regression... (tested only for mcs51-small) the testcase successfully destinguishes sdcc from a modified sdcc with disabled SDCCast.c:3961 Robert Larice ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1932509&group_id=599 |