bugAVR C Runtime Library - Bugs: bug #11494, strtol() return wrong value in the...

 
 

bug #11494: strtol() return wrong value in the underflow case

Submitted by:  None
Submitted on:  Wed 05 Jan 2005 07:31:21 AM UTC  
 
Category: LibrarySeverity: 3 - Normal
Priority: 9 - ImmediateItem Group: None
Status: FixedPercent Complete: 0%
Assigned to: Joerg Wunsch <joerg_wunsch>Originator Email: -unavailable-
Open/Closed: ClosedRelease: None
Fixed Release: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 25 Jan 2005 10:57:09 AM UTC, comment #5:

Your patch package has been incorporated, bolshoye spasibo!

Joerg Wunsch <joerg_wunsch>
Project AdministratorIn charge of this item.
Wed 12 Jan 2005 03:03:30 AM UTC, comment #4:

Sorry, a mistake in last comment. Read as:
But if anybody is needing a function, that must return value,
"exactly 32 bits length"...

Anonymous
Tue 11 Jan 2005 10:16:21 PM UTC, comment #3:

My opinion about "-mint8 compatibility":

Without -mint8 option, original (and patched) `strtol'
return `long' value, that is clipped in bounds LONG_MIN
and LONG_MAX. Such, strtol("5000000000",0,0) must return
2147483647.
With -mint8 option, `strtol' must also return `long'
value, clipped by LONG_MIN and LONG_MAX also. But, due
to reduced size of `long' (and reduced LONG_MAX, LONG_MIN),
the result of strtol("5000000000",0,0) must be 32767.
Such behavior agree, for example, glibc. On computer
with 64-bit long, result of strtol("5000000000",0,0) will
be 5000000000.

In such sence, strtol (original and patched) work true with
any size of `long'.

But if anybody is needing a function, that must return value,
"at least as 32 bits", it is necessity to write another function,
with another name, like:
int32_t strto32 (const char , char *, int) .

Thanks.

P.S. In patch #3618 (strtol optimization) second part of source
contain test for strtol with strings, like:
{ "2147483647", 0, 0x7fffffff, 0, 10 }
This test do not work with `-mint8' option and must be rewrited
with conditional compilation usage.

Anonymous
Mon 10 Jan 2005 10:51:37 PM UTC, comment #2:

In the patch for this bug, can you rewrite your typecasts using the types found in stdint.h? (for example uint32_t, uint16_t)

That way it can start to be -mint8 compatible.

Thanks!
Eric

Eric Weddington <arcanum>
Project Administrator
Thu 06 Jan 2005 07:29:29 AM UTC, comment #1:

Look, please, the optimized strtol, patch #3618. Twice speed up, and 32 bytes stack usage decrease. Code size the same.

Anonymous
Wed 05 Jan 2005 07:31:21 AM UTC, original submission:

This is very old bug.
strtol() must return LONG_MIN for inputs too small.
Original Berkeley version do it. But avr-libc's version, for example, "-5000000000" --> -705032704 (simulavr, avr-gcc 3.3.4). You can reproduce such result on any 32-bit computer.

The reason is the attemption to negative LONG_MIN value (0x80000000).
Attached patch correct this mistake. (And it excude compiler warnings in comparison).

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #2324:  strtol-20050105.diff added by None (856B - text/x-diff - Patch for strtol.c (from avr-libc-1.2.0))

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 6 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Tue 25 Jan 2005 10:57:09 AM UTCjoerg_wunschStatusNone=>Fixed
  Assigned toNone=>joerg_wunsch
  Open/ClosedOpen=>Closed
Mon 10 Jan 2005 09:48:07 PM UTCarcanumPriority7 - High=>9 - Immediate
Wed 05 Jan 2005 04:50:14 PM UTCarcanumPriority5 - Normal=>7 - High
Wed 05 Jan 2005 07:31:21 AM UTCNoneAttached File-=>Added strtol-20050105.diff, #2025

Back to the top


Powered by Savane 3.1-cleanup1