Menu
Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
stdbool.h
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="James Kuyper" data-source="post: 5149395"><p><u></u></p><p><u></u></p><p><u>As a practical matter (I'll get to issue of what the standard says</u></p><p><u>farther down), same size is insufficient to enable two types to be</u></p><p><u>compatible. They must also have the same representation and alignment</u></p><p><u>requirements, and must use the same mechanism when passed as a parameter</u></p><p><u>and when returned as the value of a function.</u></p><p><u></u></p><p><u></u></p><p><u>I've argued in the past that the standard guarantees compatibility for</u></p><p><u>certain pairs of types (which do not include "int" and "long"), but that</u></p><p><u>it does not prohibit other pairs of types from happening to be</u></p><p><u>compatible on particular implementations. I was told that the cases</u></p><p><u>where the standard specifies that two types are compatible are</u></p><p><u>exhaustive - no other pairs of types can be compatible. This is an</u></p><p><u>example of a more general rule when interpreting the standard: whenever</u></p><p><u>it provides a list of things for which something is true, that list is</u></p><p><u>exhaustive unless the standard explicitly says otherwise. I knew of that</u></p><p><u>rule, but find that argument less than compelling, because the</u></p><p><u>compatibility rules are not provided as a list, but as several</u></p><p><u>independent clauses in widely separated parts of the standard.</u></p><p><u>However, the official interpretation is that whenever a constraint</u></p><p><u>requires that two types be compatible, it is a violation of that</u></p><p><u>constraint, requiring a diagnostic, if the two types are not ones</u></p><p><u>explicitly specified as being compatible by the standard.</u></p><p><u></u></p><p><u>After issuing the required diagnostic, the implementation is free to</u></p><p><u>produce an executable anyway, and if you chose to execute the resulting</u></p><p><u>program it might behave in exactly the same fashion as would be</u></p><p><u>mandatory if the standard had specified that those two types were</u></p><p><u>compatible, and the implementation is free to document this as a fact.</u></p><p><u>However, the diagnostic message is still the only mandatory result of</u></p><p><u>translating such a program. The implementation's documentation cannot,</u></p><p><u>therefore, accurately describe this fact by saying "int and long int are</u></p><p><u>compatible"; it must use some other wording to describe that fact.</u></p></blockquote><p></p>
[QUOTE="James Kuyper, post: 5149395"] [u] As a practical matter (I'll get to issue of what the standard says farther down), same size is insufficient to enable two types to be compatible. They must also have the same representation and alignment requirements, and must use the same mechanism when passed as a parameter and when returned as the value of a function. I've argued in the past that the standard guarantees compatibility for certain pairs of types (which do not include "int" and "long"), but that it does not prohibit other pairs of types from happening to be compatible on particular implementations. I was told that the cases where the standard specifies that two types are compatible are exhaustive - no other pairs of types can be compatible. This is an example of a more general rule when interpreting the standard: whenever it provides a list of things for which something is true, that list is exhaustive unless the standard explicitly says otherwise. I knew of that rule, but find that argument less than compelling, because the compatibility rules are not provided as a list, but as several independent clauses in widely separated parts of the standard. However, the official interpretation is that whenever a constraint requires that two types be compatible, it is a violation of that constraint, requiring a diagnostic, if the two types are not ones explicitly specified as being compatible by the standard. After issuing the required diagnostic, the implementation is free to produce an executable anyway, and if you chose to execute the resulting program it might behave in exactly the same fashion as would be mandatory if the standard had specified that those two types were compatible, and the implementation is free to document this as a fact. However, the diagnostic message is still the only mandatory result of translating such a program. The implementation's documentation cannot, therefore, accurately describe this fact by saying "int and long int are compatible"; it must use some other wording to describe that fact.[/u] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
stdbool.h
Top