#64 Strtoul always returns ULONG_MAX

closed-wont-fix
libc (18)
5
2011-08-01
2011-04-11
Diane
No

Any string given to strtoul returns 0xffffffff. There is a suggested fix in the mailing list from a year ago, at http://comments.gmane.org/gmane.comp.hardware.texas-instruments.msp430.gcc.user/8365 but it looks as though it was never implemented. This error happens at run time or compile time as well.

Strtol works fine.

Discussion

  • Peter A. Bigot
    Peter A. Bigot
    2011-04-12

    The fix below has been applied in uniarch msp430-libc (hosted on the mspgcc project). I'll leave this open until I get around to patching the mspgcc4 version.

    commit f1014305458b69d77692038e67d9b48e15c3464f
    Author: Peter A. Bigot <pabigot@users.sourceforge.net>
    Date: Mon Apr 11 19:01:45 2011 -0500

    SF 3284858 Strtoul always returns ULONG_MAX

    ldiv(3) cannot be used as it is in this code, because it operates on signed
    longs and the attempt to divide ULONG_MAX by the base results in a range
    error. The bsd variant, which was used, did not have the fix that was
    applied to the stdlib variant to fix this problem. This time, let's remove
    the code that doesn't work, rather than just disable it.

     
  • Peter A. Bigot
    Peter A. Bigot
    2011-08-01

    Fixed in mspgcc; will not be fixed in mspgcc4.

     
  • Peter A. Bigot
    Peter A. Bigot
    2011-08-01

    • status: open --> closed-wont-fix