From: SourceForge.net <no...@so...> - 2012-01-14 13:08:37
|
Bugs item #2942343, was opened at 2010-01-29 08:25 Message generated for change (Comment added) made by spth You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=2942343&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: Icode generator Group: fixed Status: Closed Resolution: Fixed Priority: 3 Private: No Submitted By: Philipp Klaus Krause (spth) Assigned to: Maarten Brock (maartenbrock) Summary: Initialization of non-constant arrays broken. Initial Comment: Initialization of arrays which are not constant is currently borken. The values are not chekced for range or converted to the target type: const unsigned char x[3] = {255, 256, 257}; gives a warning about out-of-range values. unsigned char x[3] = {255, 256, 257}; does not. const _Bool foo[4] = {1, 2, 3, 4}; creates an array of 4 _Bools which all have the value true. _Bool foo[4] = {1, 2, 3, 4}; creates an array which contains the value true in foo[0], but has the rest of the array initialized by 2,3,4, which are invalid values for _Bool. Philipp ---------------------------------------------------------------------- >Comment By: Philipp Klaus Krause (spth) Date: 2012-01-14 05:08 Message: We didn't even have _Bool back then. I've seen the check uses IS_BOOLEAN, which is true for __bit and __sbit as well as _Bool. IMO we probably should do the check for _Bool; I don't know __bit and __sbit. Philipp ---------------------------------------------------------------------- Comment By: Maarten Brock (maartenbrock) Date: 2012-01-14 05:02 Message: The function checkConstantRange() was introduced with this exception by Bernhard Held in #4206. I have no idea why. In the meantime Jan Waclawek responded on the developer mailing list with: > I'd say, if unsigned char a = 256 warns, so should _Bool b = 4. > > I'd also say, unsigned char a = -128 should warn, too. ---------------------------------------------------------------------- Comment By: Philipp Klaus Krause (spth) Date: 2012-01-14 02:45 Message: I wonder why there was/is special treatment for _Bool. I'll have a look at it later. Philipp ---------------------------------------------------------------------- Comment By: Maarten Brock (maartenbrock) Date: 2012-01-14 02:17 Message: Fixed in SDCC 3.1.2 #7216. Warning for _Bool is still suppressed in checkConstantRange() in SDCCval.c. ---------------------------------------------------------------------- Comment By: Maarten Brock (maartenbrock) Date: 2012-01-11 15:34 Message: Philipp and others, I know how to add the warning. But first I have a question since the current code does not warn for _Bool with or without const. This is explicitly coded at present. Do we want a warning for these? _Bool b = 4; b = 5; Maarten ---------------------------------------------------------------------- Comment By: Philipp Klaus Krause (spth) Date: 2010-09-19 10:49 Message: I just tried in sdcc 2.9.7 #5983. The bug is partially fixed: The array of _Bool is initialized to the correct values. However the warning about out of range values is till missing for the non-const arrays of all types. Philipp ---------------------------------------------------------------------- Comment By: Maarten Brock (maartenbrock) Date: 2010-09-19 07:56 Message: Philipp, Can you please recheck this? SDCC #5982 seems to have this fixed. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=2942343&group_id=599 |