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