I am using an open source md5 c code. There are following defines:
#define F(x, y, z) ((((y) ^ (z)) & (x)) ^ (z))
#define ROTATE_LEFT(x, n) rlc_32x8((x), (n))
#define FF(a, b, c, d, x, s, ac) \
{(a) += F ((b), (c), (d)) + (x) + (ULONG)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
Where ULONG is unsigned 32-bit integer. (#define ULONG unsigned long)
It compiled ok with 3.0.0, but get "md5.c:313: warning 184: integer constant '3614090360' out of range, truncated to
2147483647." now.
Version used:
SDCC : mcs51/gbz80/z80/z180/r2k/ds390/pic16/pic14/TININative/ds400/hc08 3.1.2 #7
334 (Feb 20 2012) (MINGW32)
md5.c attached.
This seems to be a subtle difference between c89 and c99. sdcc should now correctly compile this when operating in c89 mode. If you add the "ul" suffix to the large decimal constants, it should work in either language mode
Fixed in revision #7340
I tested #7347, still the same problem there.
SDCC version: SDCC : mcs51/gbz80/z80/z180/r2k/ds390/pic16/pic14/TININative/ds400/hc08 3.1.2 #7347 (Feb 24 2012) (MINGW32)
Command line used: sdcc md5.c -mz80 -c --std-c99 --codeseg CODE6
I modified the md5.c to include everything in a single file for easy repeating the problem. But seems that I can not attach files when bug "fixed"?
Okay, I've re-openned this. It may take awhile to fix this so that it works with your source as-is in the --std-c99 mode. This is because the constants used are too large to be signed long and so according to the c99 standard must be treated as signed long long, which is currently only partially implemented.
It worked in the older revisions of sdcc because they were interpreted with the c89 rules, which allows them to be unsigned long, but sdcc should not allow that when --std-c99 is specified. For the short term, you can change the source so that the large numbers have a "ul" suffix to force them to be of type unsigned long.
compileable version with everything in a file
I updated md5_NEW.c with everything in a file for direct compile test. I will add ul to go on test other stuff. Thanks.
Duplicate to bug #1996.