Commit c7cbbcd
committed
Fix new/free mismatch when differentiating delegating constructors.
For a delegating constructor initializer, DifferentiateCtorInit replaced
`_this`'s initializer -- set by BuildThisExpr to malloc and paired with
free(_this) -- with an allocating `new ClassTy(args)`, so the new-ed
pointer was then handed to free(). Valgrind reports the mismatched
deallocation in Gradient/Constructors.C.
Emit a placement new into the malloc'd `_this` instead, as the
base-initializer path already does, keeping allocation and deallocation
malloc/free.1 parent 67937c2 commit c7cbbcd
2 files changed
Lines changed: 10 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
734 | 734 | | |
735 | 735 | | |
736 | 736 | | |
737 | | - | |
738 | | - | |
739 | | - | |
740 | | - | |
741 | | - | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
742 | 743 | | |
743 | 744 | | |
744 | 745 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | 5 | | |
8 | 6 | | |
9 | 7 | | |
| |||
368 | 366 | | |
369 | 367 | | |
370 | 368 | | |
371 | | - | |
| 369 | + | |
372 | 370 | | |
373 | 371 | | |
| 372 | + | |
374 | 373 | | |
375 | 374 | | |
376 | 375 | | |
377 | 376 | | |
378 | 377 | | |
379 | | - | |
| 378 | + | |
| 379 | + | |
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
| |||
0 commit comments