Title
TR1: div(_Longlong, _Longlong) vs div(intmax_t, intmax_t)
Status
nad editorial
Section
[cstdint.syn][tr.c99.cstdint]
Submitter
Paolo Carlini

Created on 2006-02-06.00:00:00 last changed 163 months ago

Messages

Date: 2010-10-21.18:28:33

[ 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.
Date: 2010-10-21.18:28:33

[ 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]

Date: 2010-10-21.18:28:33

[ and in [tr.c99.cinttypes.def]: ]

The header defines all functions, types, and macros the same as C99 subclause 7.8.

Date: 2010-10-21.18:28:33

[ 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);
Date: 2006-02-06.00:00:00

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...

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg3053
2010-10-21 18:28:33adminsetmessages: + msg3052
2010-10-21 18:28:33adminsetmessages: + msg3051
2010-10-21 18:28:33adminsetmessages: + msg3050
2006-02-06 00:00:00admincreate