Path: utzoo!utgpu!water!watmath!clyde!att-cb!att-ih!pacbell!ptsfa!ames!ucsd!sdcsvax!ucsdhub!hp-sdd!hplabs!hpda!hpcupt1!hpisod2!decot From: decot@hpisod2.HP.COM (Dave Decot) Newsgroups: comp.lang.c Subject: Re: Constant overflow Message-ID: <2550059@hpisod2.HP.COM> Date: 7 Mar 88 09:24:49 GMT References: <2747@mmintl.UUCP> Organization: Hewlett Packard, Cupertino Lines: 21 > Try this one on your favorite C compiler. So far, every one I've tried > (including lint) has had no complaint: > > long i = 9876543210L; > > (The problem, of course, is that that number doesn't fit in 32 bits...) My compiler and lint don't complain either. I presume this phenomenon is widespread because the algorithm used for lex'ing such constants is almost always something like "keep eating digits and multiplying by 10 (or 8 or 16 or 2) until no more digits". Optionally, this may include "...or until too many digits have been processed", but that doesn't help this particular case, since there aren't too many digits, just too much value. It's hard to do this right unless you do some clever comparison just before multiplying by 10 (or 8 or 16 or 2). Dave Decot hpda!decot