Changes between Initial Version and Version 1 of Ticket #227


Ignore:
Timestamp:
Jan 18, 2021, 3:27:25 PM (5 years ago)
Author:
mlbrooks
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #227 – Description

    initial v1  
    2222
    2323}}}
     24
     25
     26A problem comes up, under the "business as usual" interpretation, that the assertions apply to the autogen functions.  The problem is that it is possible to declare custom constructors or destructors with fewer assertions than the autogen ones; by the specialization cost element, the custom ones are less specialized than the autogen ones, so the autogen ones are still preferred.
     27
     28{{{
     29trait is_happy( otype T ) {
     30    void sayHi(T);
     31};
     32
     33forall( otype T           | is_happy(T) )
     34struct thing { T item; };
     35
     36forall( otype T
     37#ifdef REMEMBER_ASSN
     38                          | is_happy(T)
     39#endif
     40                                        )
     41void ^?{}( thing(T) & ) {
     42    printf("custom dtor called\n");
     43}
     44
     45void sayHi(float) {}
     46
     47int main() {
     48    thing(float) x;
     49}
     50}}}
     51
     52Actual, plain compile:  Compile succeeds; run produces no output, showing the custom destructor was not called.
     53
     54Expected, plain compile:  Error, you are obviously trying to declare a destructor, but because your declaration is missing an assertion, it will never be chosen.
     55
     56Actual and expected -DREMEMBER_ASSN:  Compile succeeds, custom destructor is called.  This is the state that the expected error will help the programmer reach.