|
[sdcc-devel] [ sdcc-Bugs-904237 ] pointer cast problem and sizeof(void) should'nt be 0
From: SourceForge.net <noreply@so...> - 2004-02-25 14:11
|
Bugs item #904237, was opened at 2004-02-25 14:59 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=904237&group_id=599 Category: msc51(8051) target Group: None Status: Open Resolution: None Priority: 5 Submitted By: Josef Pavlik (jetset) Assigned to: Nobody/Anonymous (nobody) Summary: pointer cast problem and sizeof(void) should'nt be 0 Initial Comment: hello I found, that is impossible to cast the type of pointer when I want to increment it. When I try something like this: void *voidptr; ((unsigned int *)voidptr)++; I got the error: 'lvalue' required for '++' operation. If I omit the parenthesis, no increment is done because no type casting is done (because the priority of operands) and the size of void is 0. If I try to add the sizeof of unsigned int: ptr+=sizeof(unsigned int); nothing happens, because in the sdcc the size of void is 0. I think that this is not right. In this case is impossible to modify an void pointer. The gcc thinks that size of void is 1, so voidptr+=sizeof(something) makes sense. I thing, that sizeof anything may not be 0. sizeof(void), increment void* etc may produce an error or something, but does not silently ignore it. My opinion is that the right way is make it 1, like makes gcc. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=904237&group_id=599 |
| Thread | Author | Date |
|---|---|---|
| [sdcc-devel] [ sdcc-Bugs-904237 ] pointer cast problem and sizeof(void) should'nt be 0 | SourceForge.net <noreply@so...> |