News for hackers. Stuff that matters.
Re:A Defer Mechanism for C by cesarb on Monday December 14, 2020 @11:03AM (#25419052)
IIRC, the problem with C++ is that you can declare anonymous object instances... With surprising results (the object is destroyed at the semicolon, instead of being destroyed at the end of the block).
Re:A Defer Mechanism for C by dkersten on Monday December 14, 2020 @12:44PM (#25420543)
Sure, you can, but its still not the behaviour you'd expect and the problem in my example is that "if it looks like a declaration, it is", so "foo bar;" and "foo (bar);" can be the same thing.
Re:A Defer Mechanism for C by gpderetta on Monday December 14, 2020 @11:46AM (#25419653)
It is quite dangerous. IIRC some compilers do catch the issue and warn about it.