Austin Group Defect Tracker

Aardvark Mark IV


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 2013-05-23 16:27
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

- Relationships

There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2013-05-19 18:12 fbauzac New Issue
2013-05-19 18:12 fbauzac Status New => Under Review
2013-05-19 18:12 fbauzac Assigned To => ajosey
2013-05-19 18:12 fbauzac Name => Fabrice Bauzac
2013-05-19 18:12 fbauzac Section => strtoul
2013-05-19 18:12 fbauzac Page Number => na
2013-05-19 18:12 fbauzac Line Number => na
2013-05-23 16:27 msbrown Project 1003.1(2004)/Issue 6 => 1003.1(2008)/Issue 7
2014-04-03 16:22 geoffclare Tag Attached: c99


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker