c++/568: virtual class destructors called with faulty this pointer

magnus.fromreide@teligent.se magnus.fromreide@teligent.se
Sun Sep 24 22:46:00 GMT 2000


>Number:         568
>Category:       c++
>Synopsis:       virtual class destructors called with faulty this pointer
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Sun Sep 24 22:45:59 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     magnus.fromreide@teligent.se
>Release:        2.95.[012], 2.91.66, 2.96 20000914
>Organization:
>Environment:
An system where vtable-thunks is on by default, verified on Linux with libc6 and on FreeBSD 3.4
Does not appear on Linux with libc5
>Description:
The compiler doesn'tt adjust the vpointer correctly when calling virtual functions on the right leaf so the this pointer will not point to this of the subobject.
>How-To-Repeat:
Compile the above program and run it.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="bug.C"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="bug.C"

I2lmIGRlZmluZWQoX19HTlVDX18pICYmIF9fR05VQ19fIDw9IDIgJiYgX19HTlVDX01JTk9SX18g
PCA5NQojICAgaW5jbHVkZSA8aW9zdHJlYW0uaD4KI2Vsc2UKIyAgIGluY2x1ZGUgPGlvc3RyZWFt
PgojZW5kaWYKCmNsYXNzIEJhc2UgewpwdWJsaWM6CiAgdmlydHVhbCB2b2lkIHZmdW5jKCkgewog
ICAgY291dCA8PCAiQmFzZTo6dmZ1bmM6ICIgPDwgKHZvaWQgKil0aGlzIDw8IGVuZGw7CiAgfQoK
ICB2b2lkIHNmdW5jKCkgewogICAgY291dCA8PCAiQmFzZTo6c2Z1bmM6ICIgPDwgKHZvaWQgKil0
aGlzIDw8IGVuZGw7CiAgfTsKfTsKCmNsYXNzIExlZnQgOiBwdWJsaWMgdmlydHVhbCBCYXNlIHsK
cHVibGljOgogIH5MZWZ0KCkgewogICAgbGZ1bmMoKTsKICB9CgogIHZvaWQgdm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