1 // GROUPS passed destructors 2 #include <stdio.h> 3 4 int destruct = 0; 5 6 class bla { 7 8 public: 9 bla(char * jim)10 inline bla(char * jim) { ; }; 11 ~bla()12 inline ~bla() { destruct++; if (destruct == 2) printf ("PASS\n");}; 13 }; 14 15 class ulk { 16 17 public: 18 ulk()19 inline ulk() {}; ~ulk()20 inline ~ulk() {}; 21 funk(const bla & bob)22 void funk(const bla & bob) { ;}; 23 // ^ interestingly, the code compiles right if 24 // this & is deleted (and therefore the parameter 25 // passed as value) 26 }; 27 main()28int main() { 29 30 ulk dumm; 31 32 dumm.funk(bla("laberababa")); // this compiles correctly 33 34 dumm.funk((bla)"laberababa"); // this produces incorrect code - 35 // the temporary instance of 36 // the class "bla" is constructed 37 // but never destructed... 38 39 40 } 41