Title
Conversions between function pointers and void*
Status
c++11
Section
7.6.1.10 [expr.reinterpret.cast]
Submitter
Steve Adamczyk

Created on 2006-04-13.00:00:00 last changed 96 months ago

Messages

Date: 2011-03-15.00:00:00

[Voted into the WP at the March, 2011 meeting.]

Date: 2010-11-15.00:00:00

Proposed resolution (November, 2010):

  1. Change _N4885_6.7.5.5.4 [basic.stc.dynamic.safety] paragraphs 1-2 as follows:

  2. A traceable pointer object is

    • an object of pointer-to-object an object pointer type (6.8.3 [basic.compound]), or

    • an object of an integral type that is at least as large as std::intptr_t, or

    • a sequence of elements in an array of character type, where the size and alignment of the sequence match that those of some pointer-to-object object pointer type.

    A pointer value is a safely-derived pointer to a dynamic object only if it has pointer-to-object an object pointer type and it is...

  3. Change 6.8.3 [basic.compound] paragraphs 3-4 as follows:

  4. The type of a pointer to void or a pointer to an object type is called an object pointer type. [Note: A pointer to void does not have a pointer-to-object type, however, because void is not an object type. —end note] The type of a pointer that can designate a function is called a function pointer type. A pointer to objects of type T is referred to as a “pointer to T.” [Example:...

    Objects of cv-qualified (6.8.4 [basic.type.qualifier]) or cv-unqualified type void* (pointer to void), A pointer to cv-qualified (6.8.4 [basic.type.qualifier]) or cv-unqualified void can be used to point to objects of unknown type. A void* Such a pointer shall be able to hold any object pointer. A cv-qualified or cv-unqualified (6.8.4 [basic.type.qualifier]) An object of type cv void* shall have the same representation and alignment requirements as a cv-qualified or cv-unqualified cv char*.

  5. Change 7.3.12 [conv.ptr] paragraph 1 as follows:

  6. ...A null pointer constant can be converted to a pointer type; the result is the null pointer value of that type and is distinguishable from every other value of pointer to object or pointer to function object pointer or function pointer type...
  7. Change 7.3.13 [conv.mem] paragraph 2 footnote 58 as follows:

  8. ...Note that a pointer to member is not a pointer to object or a pointer to function an object pointer or a function pointer and...
  9. Change 7.6.1.10 [expr.reinterpret.cast] paragraphs 6-8 as follows:

  10. A pointer to a function pointer can be explicitly converted to a pointer to a function pointer of a different type...

    A pointer to an An object pointer can be explicitly converted to a pointer to a different object type an object pointer of a different type...

    Converting a pointer to a function into a pointer to an object function pointer to an object pointer type or vice versa is conditionally-supported...

  11. Change the note in 9.3.4.6 [dcl.fct] paragraph 6 as follows:

  12. [Note: function types are checked during the assignments and initializations of pointer-to-functions, reference-to-functions, and pointer-to-member-functions pointers to functions, references to functions, and pointers to member functions. —end note]
  13. In the “Index of Implementation-defined Behavior,” change the following item as indicated:

  14. converting pointer to function into pointer to object function pointer to object pointer and vice versa

[Drafting note: 7.6.2.9 [expr.delete] paragraph 1 was not changed, so the operand of delete still cannot be a void*. 12.5 [over.built] paragraph 14 was not changed, so void* pointers still do not get overloads for operator-. 13.2 [temp.param] paragraph 4 was not changed and thus continues to allow only pointers to objects, not object pointers, as non-type template parameters.]

(See also issue 1120.)

Date: 2006-04-13.00:00:00

The resolution to issue 195 makes “converting a pointer to a function into a pointer to an object type or vice versa” conditionally-supported behavior. In doing so, however, it overlooked the fact that void is not an “object type” (6.8 [basic.types] paragraph 9). The wording should be amended to allow conversion to and from void* types.

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetstatus: ready -> fdis
2010-11-29 00:00:00adminsetstatus: drafting -> ready
2010-03-29 00:00:00adminsetstatus: review -> drafting
2010-02-16 00:00:00adminsetmessages: + msg2529
2010-02-16 00:00:00adminsetstatus: drafting -> review
2008-10-05 00:00:00adminsetstatus: review -> drafting
2008-06-29 00:00:00adminsetmessages: + msg1694
2008-06-29 00:00:00adminsetstatus: drafting -> review
2006-11-05 00:00:00adminsetstatus: open -> drafting
2006-04-13 00:00:00admincreate