Path: utzoo!attcan!uunet!cs.utexas.edu!usc!jarthur!nntp-server.caltech.edu!laguna.ccsf.caltech.edu!daveg From: daveg@near.cs.caltech.edu (Dave Gillespie) Newsgroups: comp.lang.c Subject: Re: Bug constant folding unsigned chars Message-ID: Date: 29 Jul 90 01:00:28 GMT References: <9007250601.AA07615@csvax.cs.caltech.edu> <861@intelisc.isc.intel.com> Sender: news@laguna.ccsf.caltech.edu Followup-To: comp.lang.c Organization: California Institute of Technology Lines: 33 In-Reply-To: hays@isc.intel.com's message of 27 Jul 90 20:15:17 GMT On 27 Jul 90 20:15:17 GMT, hays@isc.intel.com (Kirk Hays) said: > In article <9007250601.AA07615@csvax.cs.caltech.edu> daveg@CSVAX.CS.CALTECH.EDU (David Gillespie) writes: >>I tried the following program on gcc 1.37.1 under HP-UX 7.0. I was >>checking that IsUnsigned would be folded to a constant at compile-time. >>It was, but in two cases the result was wrong! [it worked for unsigned int, but not for unsigned short or unsigned char] > Sorry, but the macro is K&R correct(sometimes), ANSI wrong, as the value > conversion rules were open in K&R, but defined in ANSI. > What you are seeing is ANSI compiler behavior. [explanation of ANSI promotion rules] > Frankly, I am surprised that Karl Heuer blew the macro; he is the walking > lint, after all! Karl's original message said the macro tested the *promoted* type of the argument. I just forgot the distinction, having grown up with pre-ANSI compilers which used different promotion rules. Sorry for the confusion---Karl's track record is intact! Now, whether I *agree* with ANSI's promotion rules is... well, let's not start that again. Can anybody see a way to define IsUnsigned that does check the true type of the argument? -- Dave -- Dave Gillespie 256-80 Caltech Pasadena CA USA 91125 daveg@csvax.cs.caltech.edu, ...!cit-vax!daveg