-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Open
Labels
clang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.
Description
It seems #63818/#89154 haven't been quite fixed yet. In some sense, I think the fix actually made things worse, because we now get a double-destruction (which is more likely to cause a security issue) instead of neglecting to run a destructor (which would've been more likely to cause a leak instead).
#include <stdio.h>
struct D {
~D() { printf("[%p] D::~D()\n" , this); }
D() { printf("[%p] D::D()\n" , this); }
D(int x) { printf("[%p] D::D(int %d)\n" , this, x); }
D(D const &other) { printf("[%p] D::D(D const & %p)\n", this, &other); }
};
struct S { D d; int i; };
static S f() { return S{ D(1), ({ return S(); 0; }) }; }
int main() { return f().i; }Clang (trunk):
[0x7ffdfbc4df68] D::D(int 1)
[0x7ffdfbc4df68] D::D()
[0x7ffdfbc4df68] D::~D()
[0x7ffdfbc4df68] D::~D()
Clang 18.1.0:
[0x7fffa42f9e60] D::D(int 1)
[0x7fffa42f9e60] D::D()
[0x7fffa42f9e60] D::~D()
Expected behavior: The D(1) subobject should be destroyed before S() constructs an object on top of it.
Actual behavior: The object is constructed twice at the same location, then destroyed twice at the same location.
Metadata
Metadata
Assignees
Labels
clang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.