[PATCH] Fix memory leak for APValues that do memory allocation.

Richard Smith richard at metafoo.co.uk
Fri May 10 14:45:06 PDT 2013

Comment at: lib/AST/APValue.cpp:235-240
@@ +234,8 @@
+    return getComplexFloatReal().needsCleanup();
+  case ComplexInt:
+    assert(!getComplexIntReal().needsCleanup() &&
+           "_Complex cannot be created with large enough real values.");
+    assert(!getComplexIntImag().needsCleanup() &&
+           "_Complex cannot be created with large enough real values.");
+    return false;
+  case LValue:
Manuel Klimek wrote:
> Richard Smith wrote:
> > This seems likely to bite us in the future. Please implement this "properly" rather than asserting, even though it can't happen today.
> So, do we need to check both here? Or is only one enough? Given how little I understand about the code I'm wary of implementing anything without being able to write any tests.
> I'll give in eventually, but my gut feeling tells me that I'd want to know in the future when this changes, so I can go and write some test for it...
Just checking one of them is fine. How about adding a test to your existing test suite which just checks that compile fails for _Complex __int128, with a comment indicating that it shouldn't leak if it works? That way, whoever adds support for that will know to update the test.




More information about the cfe-commits mailing list