Anonymous | Login | 2025-01-22 18:21 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 | ||
0000918 | [1003.1(2013)/Issue7+TC1] System Interfaces | Editorial | Error | 2015-02-04 22:17 | 2019-06-10 08:54 | ||
Reporter | safinaskar | View Status | public | ||||
Assigned To | |||||||
Priority | normal | Resolution | Accepted | ||||
Status | Closed | ||||||
Name | Askar Safin | ||||||
Organization | |||||||
User Reference | |||||||
Section | getaddrinfo | ||||||
Page Number | 2013 edition, p. 927 | ||||||
Line Number | 31262 | ||||||
Interp Status | --- | ||||||
Final Accepted Text | |||||||
Summary | 0000918: C99 forbids "struct addrinfo hints = {}" | ||||||
Description | - | ||||||
Desired Action |
-31262 struct addrinfo hints = {}; +31262 struct addrinfo hints = {0}; |
||||||
Tags | tc2-2008 | ||||||
Attached Files | |||||||
|
Relationships | |||||||||||
|
Notes | |
(0002535) geoffclare (manager) 2015-02-05 09:59 |
In addition to the problem raised here, there are a couple of problems with the related text on Page 924 Line 31149, "In this hints structure every member other than ai_flags, ai_family, ai_socktype, and ai_protocol shall be set to zero or a null pointer." 1. This is intended to be a requirement on the application, and so should be worded as "The application shall ensure that ..." 2. It is not clear whether "every member" refers only to the standard members or includes any non-standard additional members. I.e. can applications just set the standard members explicitly and leave any non-standard additional members with indeterminate values, or do they have to use a form of initialisation (as in the example) that implicitly sets all non-standard additional members to zero/null? |
(0002538) jilles (reporter) 2015-02-06 14:52 |
The proposed initializer causes a compiler warning (missing initializer) at strict settings (-Wall -Wextra) of gcc and clang. The compilers do not complain if a designated initializer is used, like: struct addrinfo hints = { .ai_flags = 0 }; The following four lines can be folded into the initializer as well: struct addrinfo hints = { .ai_family = AF_UNSPEC, .ai_socktype = SOCK_DGRAM, .ai_flags = AI_PASSIVE }; |
(0002539) safinaskar (reporter) 2015-02-06 17:57 |
Missing initializer is just a warning, "hints = {0}" still confirms to C99. But "hints = {.ai_flags = 0}" is bad, for example, because it is not supported in C++, even in C++14 |
(0002540) dalias (reporter) 2015-02-06 19:23 edited on: 2015-04-23 15:10 |
The warning mentioned in note 0002538 should be fixed as part of the resolution of gcc bug 53119 ( https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119 [^] ). If it's not, this should be reported. {0} is the correct idiomatic "universal zero initializer" especially for types whose details are not specified, and compilers should not be discouraging its use. For example it's the only portable way to initialize mbstate_t. |
(0002541) safinaskar (reporter) 2015-02-06 23:51 |
gcc 4.9.2 already doesn't report this warning (gcc 4.9.2-10 in Debian). (and dalias, please, put space after links, your link now points to non-existent bug number "53119)") |
(0002542) safinaskar (reporter) 2015-02-07 00:13 |
Same bug in clang: http://llvm.org/bugs/show_bug.cgi?id=21689 [^] |
(0002636) Don Cragun (manager) 2015-04-23 16:33 |
An additional bug will be filed to address the issues raised in Note: 0002535. |
Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group |