New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[c.limits] Remove an incorrect note about type of constant macros #667
Conversation
The note implies that the types of constant macros defined in <climits> may differ from that of C, but no nomative rule say so, and there is no reason to allow such incompatibilities. The note was added as the resolution of LWG issue cplusplus#416. http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#416 But the analysis, which based on rules of integer constants, was wrong: The type of constant macros are defined in C99 (5.2.4.2.1 p1) by rules of integer promotions. So LONG_MAX always has type long (integer promotions has no effect for long), even if the actual range of long and int are equal. That should hold in C++, too.
But what about:
Those do not have type
does not have type |
Yes they should have type
This should print "127", instead of ASCII DEL character. Same applies to If Do you want LWG issue for that? I think nobody want that. |
That's exactly what the note is saying. It says that SCHAR_MAX might not have type signed char. Going back to your first comment:
No it doesn't. That's not what the note says. |
Ah, ... (quote from [c.limits])
I misread "the type to which they refer" as "the type of them in the If so, is it obvious for native English readers? (I'm not.) However, I suspect it is still preferable to remove the note |
Maybe, there is too much insistence that C++ must exactly copy C standardese word-for-word, or say nothing at all? (quote from [c.limits]) The contents are the same as the Standard C library header <limits.h>. [ Note: The types of the constants defined by macros in are not required to match the types to which the macros refer. -end note ] I misread "the type to which they refer" as "the type of them in the Standard C library". But it was in fact "their corresponding type" (in C terminology, for type-min/max constants). Right? If so, is it obvious for native English readers? (I'm not.) However, I suspect it is still preferable to remove the note, since the reference C standard is now C99, which define the type of the constants precisely. I think the note was somewhat effective with C90, which didn't have definition of their types. Having the note only on (not on ) is another reason. — |
I'm sorry. My above comment "... C90, which didn't have definition of |
That's wrong. That is not a valid interpretation of the note, and I don't think a fluent English speaker would read it that way.
I'm not sure what you mean by "corresponding type". The type to which they refer means the type referred to by the name. INT_MAX refers to int, CHAR_MAX refers to char, etc. I don't think "corresponding type" is any clearer or less ambiguous.
The meaning seems obvious to me. I certainly don't think striking a note that LWG added to resolve a defect report is editorial. |
Thank you very much for clarifications. Now I understood this PR was I used "corresponding type" as it is used in the C standard to define
|
The note implies that the types of constant macros defined in
may differ from that of C, but no nomative rule say so, and there is no
reason to allow such incompatibilities.
The note was added as the resolution of LWG issue #416.
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#416
But the analysis, which based on rules of integer constants, was wrong:
The type of constant macros are defined in C99 (5.2.4.2.1 p1) by rules
of integer promotions. So LONG_MAX always has type long (integer
promotions has no effect for long), even if the actual range of long and
int are equal. That should hold in C++, too.
Please note that there is no such note for constant macros defined in
.
FYI, the tyepes of the constant macros are defined in C99 5.2.4.2.1, p1.
Integer promotions are defined as following in C99 6.3.1.1 p2.
I'm posting this here as an editorial issue because it is only a removal
of a "Note:" But I also have feeling that this should go as a LWG issue
because it reverts the resolution of an old LWG isseue. Please let me
know if someone know which is preferable.