#1913 MSVC-style itoa function compiled wrong

closed-fixed
None
7
2013-05-25
2012-01-19
Woody
No

I did not use any standard sdcc libary. I got my itoa function from MSVC runtime c source code. Compared with the itoa source code in sdcc lib, it only has difference in the last "swap value" step, where Microsoft code uses pointers to compare. It used to be correct with 3.0.0 version. But failed to swap in recent versions. For example, "192" is output as "291" now.
SDCC : mcs51/gbz80/z80/z180/r2k/ds390/pic16/pic14/TININative/ds400/hc08 3.1.2 #7237 (Jan 18 2012) (MINGW32)
command line used: C:\SDCC\BIN\sdcc misc.c -mz80 -c --std-c99 --codeseg CODE
misc.c attached.

Discussion

  • Woody
    Woody
    2012-01-19

     
    Attachments
  • This is not a z80-specific bug. I just tried the gbz80 and hc08 ports, and I see the same bug there. Increasing priority to 7, since bad code is silently generated.

    I have added the regression test bug3475656.c in revision #7247. If the #if 0 is changed to #if 1 it fails (except for test-host).

    Philipp

     
    • labels: 100692 -->
    • priority: 5 --> 7
     
  • Erik Petrich
    Erik Petrich
    2012-02-21

    • milestone: --> fixed
    • assigned_to: nobody --> spth
    • status: open --> closed-fixed
     
  • Erik Petrich
    Erik Petrich
    2012-02-21

    Philipp's fix for bug #3482217 also fixed this
    (Fixed in revision #7276)

     
  • Woody
    Woody
    2012-02-21

    Confirm bug fixed.
    Find new problem with current build and filed bug 3489899.