#1420 explicit typecast is ineffective for unsigned char parameter

closed-fixed
7
2013-05-25
2008-01-18
No

The compiler seems to ignore the explicit (unsigned char) typecast when it is applied to the actual parameter of a function with variable arguments. (Explicit (unsigned char) typecast is necessary even for unsigned char type otherwise the compiler would automatically push a two byte integer onto the stack.) The bug for example blocks the use of printf() function with "%bu" format specifier.

C:\>sdcc -v
SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.7.4 #4972 (Nov 23 2007) (MINGW32)

C:\>ver

Microsoft Windows XP [Version 5.1.2600]

Discussion

<< < 1 2 (Page 2 of 2)
  • Borut Ražem

    Borut Ražem - 2008-02-24
    • milestone: --> fixed
    • status: open --> closed-fixed
     
  • Borut Ražem

    Borut Ražem - 2008-02-24

    Logged In: YES
    user_id=568035
    Originator: NO

    Fixed as proposed in my previous post: casts of the same type of actual function parameters aren't removed (optimized). The ISO C standard nonconformity (or sdcc extension) remains and backward compatibility is not broken.

    Borut

     
  • Maarten Brock

    Maarten Brock - 2008-02-24

    Logged In: YES
    user_id=888171
    Originator: NO

    Borut,
    Unless I am mistaken this holding on to the cast is only relevant for varargs functions. Looking at your patch is it not possible to change .actualArgument to .actualVarArg and only set it for a varargs function? This could keep the loss of other optimizations low.
    Maarten

     
  • Borut Ražem

    Borut Ražem - 2008-02-24

    Logged In: YES
    user_id=568035
    Originator: NO

    Maarten, you are right. I committed the version which implements the values.removedCast flag, as you proposed. Please review the fix. I'm not sure if testing for IS_AST_SYM_VALUE (*actParm) is correct and needed when testing for AST_VALUES (*actParm, removedCast).

    Borut

     
<< < 1 2 (Page 2 of 2)

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks