Talk:c/language/cast
From cppreference.com
[edit] Pointers <-> Integers
- There is a contradiction in the page text:
- "Any integer can be cast to any pointer type." and "Any pointer type can be cast to any integer type."
- "there are no conversions between pointers to functions and integers".
- The Standard (6.3.2.3 Pointers, paragraphs 5 and 6) says "An integer may be converted to any pointer type." and "Any pointer type may be converted to an integer type."
- Therefore, I think point 2 above should be removed from the page.
- However, there is a very important point from the Standard (paragraph 6) which basically renders any sort of actually useful software completely impossible to write:
- "Any pointer type may be converted to an integer type[…] The result need not be in the range of values of any integer type."
- That fact should probably be noted somewhere.
- The value of a pointer-to-function is going to be stored in some object, yet there is no dependable way to recover that value. Crazy!
97.116.53.9 16:54, 10 August 2021 (PDT)