Re[2]: [cc65] Another bug... ?

Date view Thread view Subject view

From: groepaz (groepaz_at_gmx.net)
Date: 2002-07-18 19:14:20


Hello Ullrich,

Thursday, July 18, 2002, 4:54:31 PM, you wrote:


UvB> Hi!

UvB> On Thu, Jul 18, 2002 at 04:05:03PM +0200, groepaz wrote:
>> look at this, problem is a case value of "0x8000" (min_int) used in a
>> switch statement where the switch is done by a signed int.

UvB> Ok, I've checked the standard and it says that integer promotions on the
UvB> controlling variable should be applied. This would mean that the compiler does
UvB> indeed behave incorrectly - it should convert the variable i instead of
UvB> complaining.

yeah thought so.... i was surprised actually that it didnt work like
this (i used turbo-c 2.0 for cross checking -coz it has 16bit ints-
and it worked there)

UvB> I have to admit that I'm not happy about this. The code is unclean, and doing
UvB> a type conversion on i for each label that does not have the same type
UvB> introduces quite some overhead under the hood. But then, the standard is the
UvB> standard is the standard...:-)

hehe indeed :o)

UvB> Thanks for the report, I will see what I can do about it.

maybe i should tell what i was doing, so its clear why i am actually
complaining.... i was doing (working on filesystem ;=P) a function
like...

#define flag1   0x8000
#define flag2   0x4000

#define parm1   flag1
#define parm2   (flag2|flag1)

int foo(int parm){
    switch(parm){
                 case parm1:
                      break;
                 case parm2:
                      break;
    }
}

.... i guess you can see where the problem lies... that is, the
function in question MUST take an int (standard..hello! :o)) (it would
have worked with unsigned int or short without problem) although the
parameter-values are basically constructed "typeless" (or call it
bitfield or whatever). ofcoz in this case i could have dealt with that
myself (convert to unsigned before manually etc) but i guess it can
easily lead into more problems with existing code. (using 16bit-ints
as bitfields like this is probably not very uncommen across old dos code and
alike)

however, theres another sweetie:

if( ".\"."[1] != '"' ) printf("fixme!");

:=P

btw there seems to be a problem with promoting ints to longs
aswell.... ;/ (gotta come up with testcode ;=P)

-- 
Best regards,
 groepaz                            mailto:groepaz_at_gmx.net


----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2002-07-18 19:14:43 CEST