Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Why doesn't &amp;Base::foo get the correct C++ member address?</p> </blockquote> <p>Pointers to member are different types than pointers (they are, in fact, more <em>offsets</em> than types themselves) and, in particular, they cannot be converted to <code>void*</code> (they can on GCC, but it's probably a compiler extension).</p> <p>See Paragraph 8.3.3/3 of the C++11 Standard:</p> <blockquote> <p>A pointer to member shall not point to** a static member of a class (9.4), a member with reference type, or “cv void.” [ Note: See also 5.3 and 5.5. <strong>The type “pointer to member” is distinct from the type “pointer”</strong>, that is, a pointer to member is declared only by the pointer to member declarator syntax, and never by the pointer declarator syntax. There is no “reference-to-member” type in C++. —end note ]</p> </blockquote> <p>Also, Paragraph 5.2.10/10 (about <code>reinterpret_cast&lt;&gt;</code>) defines the only possible conversions for pointers to member as follows:</p> <blockquote> <p>A prvalue of type “pointer to member of X of type T1” can be explicitly converted to a prvalue of a different type “pointer to member of Y of type T2” if T1 and T2 are both function types or both object types. The null member pointer value (4.11) is converted to the null member pointer value of the destination type. The result of this conversion is unspecified, except in the following cases:</p> <p>— converting a prvalue of type “pointer to member function” to a different pointer to member function type and back to its original type yields the original pointer to member value.</p> <p>— converting a prvalue of type “pointer to data member of X of type T1” to the type “pointer to data member of Y of type T2” (where the alignment requirements of T2 are no stricter than those of T1) and back to its original type yields the original pointer to member value.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload