View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000384 | 1003.1(2008)/Issue 7 | Base Definitions and Headers | public | 2011-02-22 18:52 | 2016-07-28 15:10 |
Reporter | eblake | Assigned To | ajosey | ||
Priority | normal | Severity | Objection | Type | Omission |
Status | Closed | Resolution | Rejected | ||
Name | Eric Blake | ||||
Organization | Red Hat | ||||
User Reference | ebb.va_end | ||||
Section | stdarg.h | ||||
Page Number | 339 | ||||
Line Number | 11403 | ||||
Interp Status | --- | ||||
Final Accepted Text | |||||
Summary | 0000384: the stdarg macros should not modify errno | ||||
Description | Line 25639 [XSH errno] is explicit that "The setting of errno after a successful call to a function is unspecified unless the description of that function specifies that errno shall not be modified." However, none of the stdarg macros (va_start, va_copy, va_arg, va_end) mention their interaction with errno, which renders common code like this undefined, all because the successful va_end() invocation occurs between the point of the failure and the actual error reporting: // error-checking variant of snprintf int xsnprintf(char *str, size_t size, const char *fmt, ...) { va_list ap; int ret; va_start(ap, fmt); ret = vsprintf(str, size, fmt, ap); va_end(ap); if (ret < 0) { perror("vsprintf failed"); exit(EXIT_FAILURE); } return ret; } Typically, all va_* macros have no effect on errno, so we might as well require that, which would make the above example conforming. | ||||
Desired Action | After line 11403 [XCU <stdarg.h> DESCRIPTION], add a sentence with CX shading: The four macros defined in this header shall not change the value of errno. | ||||
Tags | No tags attached. |
related to | 0000401 | Closed | ajosey | ferror should not modify errno |
related to | 0000385 | Closed | ajosey | free should not change errno on success |
related to | 0000447 | Closed | ajosey | strerror_r and strerror_l error checking |
related to | 0000397 | Closed | ajosey | setbuf and errno |
related to | 0000511 | Closed | ajosey | getuid and friends should not modify errno |
|
The intention is to match the C Standard, where the wording is: (7.5 para 3) "The value of errno may be set to nonzero by a library function call whether or not there is an error, provided the use of errno is not documented in the description of the function in this International Standard." The use of "library function call" here makes it clear that it does not apply to macros such as va_start(). It is worth creating a new bug that cleans up the use of the word "function" throughout the standard (in some instances, such as htonl on page 1097, the word "function" was used in the mathematical sense of an interface that defines a mapping even though that interface is only a C macro, rather than in the C sense of external linkage). |
Date Modified | Username | Field | Change |
---|---|---|---|
2011-02-22 18:52 | eblake | New Issue | |
2011-02-22 18:52 | eblake | Status | New => Under Review |
2011-02-22 18:52 | eblake | Assigned To | => ajosey |
2011-02-22 18:52 | eblake | Name | => Eric Blake |
2011-02-22 18:52 | eblake | Organization | => Red Hat |
2011-02-22 18:52 | eblake | User Reference | => ebb.va_end |
2011-02-22 18:52 | eblake | Section | => stdarg.h |
2011-02-22 18:52 | eblake | Page Number | => 339 |
2011-02-22 18:52 | eblake | Line Number | => 11403 |
2011-02-22 18:52 | eblake | Interp Status | => --- |
2011-03-10 16:39 | eblake | Note Added: 0000691 | |
2011-03-10 16:40 | eblake | Status | Under Review => Closed |
2011-03-10 16:40 | eblake | Resolution | Open => Rejected |
2016-07-28 15:06 | eblake | Relationship added | related to 0000401 |
2016-07-28 15:06 | eblake | Relationship added | related to 0000385 |
2016-07-28 15:07 | eblake | Relationship added | related to 0000447 |
2016-07-28 15:08 | eblake | Relationship added | related to 0000397 |
2016-07-28 15:10 | eblake | Relationship added | related to 0000511 |