This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD Editorial status.
Section: 17.4.1 [cstdint.syn], 99 [tr.c99.cstdint] Status: NAD Editorial Submitter: Paolo Carlini Opened: 2006-02-06 Last modified: 2023-02-07
Priority: Not Prioritized
View all other issues in [cstdint.syn].
View all issues with NAD Editorial status.
Discussion:
I'm seeing a problem with such overloads: when, _Longlong == intmax_t == long long we end up, essentially, with the same arguments and different return types (lldiv_t and imaxdiv_t, respectively). Similar issue with abs(_Longlong) and abs(intmax_t), of course.
Comparing sections 8.25 and 8.11, I see an important difference, however: 8.25.3 and 8.25.4 carefully describe div and abs for _Longlong types (rightfully, because not moved over directly from C99), whereas there is no equivalent in 8.11: the abs and div overloads for intmax_t types appear only in the synopsis and are not described anywhere, in particular no mention in 8.11.2 (at variance with 8.25.2).
I'm wondering whether we really, really, want div and abs for intmax_t...
Proposed resolution:
[ Portland: no consensus. ]
Rationale:
[ Batavia, Bill: The <cstdint> synopsis in [tr.c99.cinttypes.syn] contains: ]
intmax_t imaxabs(intmax_t i); intmax_t abs(intmax_t i); imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom); imaxdiv_t div(intmax_t numer, intmax_t denom);
[ and in [tr.c99.cinttypes.def]: ]
The header defines all functions, types, and macros the same as C99 subclause 7.8.
[ This is as much definition as we give for most other C99 functions, so nothing need change. We might, however, choose to add the footnote: ]
[Note: These overloads for abs and div may well be equivalent to those that take long long arguments. If so, the implementation is responsible for avoiding conflicting declarations. -- end note]
[ Bellevue: NAD Editorial. Pete must add a footnote, as described below. ]
[ Looks like a real problem. Dietmar suggests div() return a template type. Matt: looks like imaxdiv_t is loosly defined. Can it be a typedef for lldiv_t when _Longlong == intmax_t? PJP seems to agree. We would need a non-normative note declaring that the types lldiv_t and imaxdiv_t may not be unique if intmax_t==_longlong. ]