News for hackers. Stuff that matters.
Re:A bug in GCC that may cause memory leaks in valid C++ pro... by muizelaar on Thursday April 27, 2017 @10:44PM (#14216544)
Compiling with exceptions can still have performance cost because the addition of implicit control flow at every function call.

For example the following code will compile differently depending on whether goo() can throw.

struct k { void p[4]; };

void goo(k s);

k foo() { k r; k s; goo(&s); r = s; return r; }

If goo() doesn't throw the extra variable s can be eliminated.

Re:A bug in GCC that may cause memory leaks in valid C++ pro... by int_19h on Friday April 28, 2017 @01:03AM (#14216971)
If goo doesn't throw, why not declare it nothrow?

Although I still don't see why, in your example, one of the variables cannot be elided even if goo does throw. Since there's no point at which address of r is taken, much less escapes the scope, it should always be safe to elide r and just return s, no?

Re:A bug in GCC that may cause memory leaks in valid C++ pro... by aristidb on Thursday April 27, 2017 @10:54PM (#14216574)
Try indenting your code section by 4 spaces. :)
Re:A bug in GCC that may cause memory leaks in valid C++ pro... by flamedoge on Friday April 28, 2017 @02:18AM (#14217222)
you mean r? you can't eliminate s regardless of goo throwing.