Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's a bug, and it's not specific to C++/CLI.</p> <p><a href="https://connect.microsoft.com/VisualStudio/feedback/details/100917/argument-const-ness-is-part-of-member-function-type-signature" rel="nofollow noreferrer">https://connect.microsoft.com/VisualStudio/feedback/details/100917/argument-const-ness-is-part-of-member-function-type-signature</a></p> <p>Fact is, the C++ compiler is supposed to strip off top-level const/volatile. Only const/volatile on the pointed-to type of a pointer or reference matters. If the compiler did that correctly, the CLR wouldn't have a say in what's going on.</p> <p>BTW this is the IL generated by the compiler with /clr:pure</p> <pre><code>.class private abstract auto ansi beforefieldinit Base extends [mscorlib]System.Object { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { .maxstack 1 L_0000: ldarg.0 L_0001: call instance void [mscorlib]System.Object::.ctor() L_0006: ret } .method public hidebysig newslot abstract virtual instance void Foo(int32 modopt([mscorlib]System.Runtime.CompilerServices.IsConst)) cil managed { } } .class private auto ansi beforefieldinit Derived extends Base { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { .maxstack 1 L_0000: ldarg.0 L_0001: call instance void Base::.ctor() L_0006: ret } .method public hidebysig virtual instance void Foo(int32 i) cil managed { .maxstack 0 L_0000: ret } } </code></pre> <p>This definitely violates the rule James listed concerning deletion of top-level qualifiers.</p> <p>Further relevant sections of the C++/CLI spec:</p> <blockquote> <p>8.8.10.1 Function overriding</p> <p>[snip]</p> <ol> <li>A derived class function explicitly overrides a base class virtual function having the same name, parameter-type-list, and cv-qualification, by using the function modifier override, with the program being ill-formed if no such base class virtual function exists</li> </ol> <p>12.3 Declarator types</p> <p>The C++ Standard (§8.3.5/3) is augmented, as follows:<br> The resulting list of transformed parameter types and the presence or absence of the ellipsis is the function’s parameter-type-list.</p> </blockquote> <p>So I am led to believe that the rule on deletion of cv-qualifiers applies to C++/CLI as well, because the spec specifically calls out section 8.3.5/3 of ISO Standard C++.</p>
    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.
 

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