[Bug c++/42983] [C++0x] Defaulted virtual destructor isn't virtual

2010-02-08 Thread albrt2000 at gmail dot com


--- Comment #9 from albrt2000 at gmail dot com  2010-02-08 13:58 ---
(In reply to comment #6)
> Interesting. Thus I get Core 906 [Ready] as meaning that this snippet is just
> illegal, and should be rejected, in other terms, this is an accept invalid,
> right?
> 
Hi,
I'm not sure to understand your last comment (sorry I 'm not a natural english
speaker). Do you mean that virtual ~A() = default; should be an error ? If we
can not default virtual destructor, well, the feature seems less interesting.
I opened a discussion about this in comp.std.c++ (C++0x : virtual destructor
and =default) and Scott Meyers replies that this (virtual ~A() = default;)
should be correct. Those that should be a valid gcc problem.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42983



[Bug c++/42983] [C++0x] Defaulted virtual destructor isn't virtual

2010-02-08 Thread albrt2000 at gmail dot com


--- Comment #12 from albrt2000 at gmail dot com  2010-02-08 14:24 ---
Ok. So, gcc is conformant with the document you mentioned. I am reporting this
discussion in comp.std.c++ since it makes me think that this behaviour reduces
one of the interest of the default declaration.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42983



[Bug c++/42983] [C++0x] Defaulted virtual destructor isn't virtual

2010-02-08 Thread albrt2000 at gmail dot com


--- Comment #13 from albrt2000 at gmail dot com  2010-02-08 14:25 ---
> 
> struct A {
>   virtual ~A();
> };
> 
> A::~A() = default;
> 
> I think this should be OK (but maybe not in GCC 4.4 only in 4.5)
> 
This already works in gcc 4.4.1 that I use.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42983



[Bug c++/42983] [C++0x] Defaulted virtual destructor isn't virtual

2010-02-08 Thread albrt2000 at gmail dot com


--- Comment #15 from albrt2000 at gmail dot com  2010-02-08 14:49 ---
(In reply to comment #14)
> Basing on Core 906, seems rather straightforward that the snippet is
> ill-formed, the only problem is that neither 4.4 nor current mainline reject
> it.

That's also should be the case for non public access :
struct A {
private : /* or protected */
  ~A() = default;
};
should also be illed formed according to that report.

> If that's the complete analysis, the issue is pretty low priority.
Destroying an object from a base class pointer whose destructor is not virtual
is an undefined behaviour according to the standard. I tend to think that
silently removing the virutal property when considering the default
declaration, introduces a serious bug in the code.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42983



[Bug c++/42992] New: [C++0x] =default erases virtual declaration of a destructor.

2010-02-07 Thread albrt2000 at gmail dot com
Hello,

Following code :
#include 

struct A {
virtual ~A()=default;

};

struct B : public A {
virtual ~B() {
std::cout << "B destructor\n";
}

};

int main() {
B* b = new B;
A* pA = b;
delete pA;
return 0;
}
outputs nothing, B destructor is not called as if A destructor was not
considered as virtual.

However, following code works fine :
#include 

struct A {
virtual ~A();
};

A::~A()=default;

struct B : public A {
virtual ~B() {
std::cout << "B destructor\n";
}

};

int main() {
B* b = new B;
A* pA = b;
delete pA;
return 0;
}
It outputs "B destrucor".
Having to separate virtual declaration from default definition seems to be out
of spec.

Bug found with MinGW/gcc 4.4.1..
Compilation command :
mingw32-g++.exe -Wall -fexceptions  -Wmain -pedantic -W -g -std=c++0x -c
main.cpp -o obj\Debug\main.o
mingw32-g++.exe  -o bin\Debug\TestCpp.exe obj\Debug\main.o  

Best Regards
Albert.


-- 
   Summary: [C++0x] =default erases virtual declaration of a
destructor.
   Product: gcc
   Version: 4.4.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
    ReportedBy: albrt2000 at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42992