(C++) call.c patch

Gabriel Dos Reis gdr@codesourcery.com
Mon Nov 13 07:30:00 GMT 2000


Jason Merrill <jason@redhat.com> writes:

| >>>>> "Eric" == Eric Christopher <echristo@cygnus.com> writes:
| 
| I don't think you've sent this one to gcc-patches yet, so I've taken
| the liberty of passing it on.
| 
| > This one has a testcase of:
| 
| > #include <cstdio>
| 
| > struct A {
| >   A() {}
| >   ~A() {}
| > };
| 
| > const A a;
| > int main()
| > {
| >   a.A::~A();
| > }
| 
| > And the error message is:
| 
| > t.cc: In function `int main ()':
| > t.cc:17: passing `const A' as `this' argument of `A::~A ()' 
| 
| > This appears to be valid code and the patch below makes the symptoms
| > look correct with no regressions.
| 
| > Is it correct?
| 
| It's correct, but I'd prefer to fix this bug in the code that handles
| destructors, namely build_delete.

Well, althought the program might be exercising an ill-behaviour from
the compiler part, I think the program has an undefined behaviour: The
destructor for `a' will be run twice.  Or am I missing something?

-- Gaby
CodeSourcery, LLC                       http://www.codesourcery.com


More information about the Gcc-patches mailing list