Anonymous | Login | 2023-03-29 12:53 UTC |
Main | My View | View Issues | Change Log | Docs |
Viewing Issue Simple Details [ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||||||
ID | Category | Severity | Type | Date Submitted | Last Update | |||||||
0000700 | [1003.1(2008)/Issue 7] System Interfaces | Comment | Clarification Requested | 2013-05-19 18:12 | 2023-02-16 16:41 | |||||||
Reporter | fbauzac | View Status | public | |||||||||
Assigned To | ajosey | |||||||||||
Priority | normal | Resolution | Open | |||||||||
Status | Under Review | |||||||||||
Name | Fabrice Bauzac | |||||||||||
Organization | ||||||||||||
User Reference | ||||||||||||
Section | strtoul | |||||||||||
Page Number | na | |||||||||||
Line Number | na | |||||||||||
Interp Status | --- | |||||||||||
Final Accepted Text | ||||||||||||
Summary | 0000700: Clarify strtoul's behaviour on strings representing negative numbers | |||||||||||
Description |
In which cases does strtoul (and other strtou* functions) fail with ERANGE? How is the range check performed? This ticket follows the discussion about strtoul on austin-group-l in May 2013. The RETURN VALUE section in http://pubs.opengroup.org/onlinepubs/009696799/functions/strtoul.html [^] says: If the correct value is outside the range of representable values, {ULONG_MAX} or {ULLONG_MAX} shall be returned and errno set to [ERANGE]. Some people understand this as "if the value I read (the correct value) is outside the [0, ULONG_MAX] range, then strtoul fails with ERANGE". However, it seems that many implementations do the following: 1. Read independently the optional sign and the subject [0-9]+ sequence 2. If the subject sequence fits in the unsigned long type, then store it in an unsigned long variable. Otherwise (outside the [0, ULONG_MAX] range), fail with ERANGE. 3. If there was a minus sign, then apply negation on the unsigned long variable as if it were a signed long. According to the discussion on the austin-group-l mailing list, it looks like this is what the POSIX standard (and the C standard) intend to specify. But it looks like it is not clear enough in the specification. |
|||||||||||
Desired Action |
In section "RETURN VALUE", replace - If the correct value is outside the range of representable values with either of: + If the nonnegated value is outside the range of representable values or + If the unnegated value is outside the range of representable values or + If the value before potential negation is outside the range of representable values or + If the absolute value is outside the range of representable values or something similar |
|||||||||||
Tags | c99 | |||||||||||
Attached Files | ||||||||||||
|
![]() |
|
(0006150) nick (manager) 2023-02-16 16:41 edited on: 2023-02-16 16:45 |
During the 2022-02-13 - 2022-02-17 meeting, WG14 accepted paper https://www.open-std.org/jtc1/sc22/WG14/www/docs/n3107.pdf [^] (16 in favor, 0 against, 0 abstains). The C23 standard will contain the following change:
|
Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group |