This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
g++ 4.1.1 Missing warning
- From: andrew at walrond dot org
- To: gcc at gcc dot gnu dot org
- Date: Thu, 22 Jun 2006 13:59:42 +0000
- Subject: g++ 4.1.1 Missing warning
I was surprised when this erroneous line didn't give an error:
Bifilter _bif(new Filter(),Bifilter::DELETE_ON_DESTRUCTION);
when the Bifilter constructor is defined as
class Bifilter : public Filter
{
public:
enum DestructorAction { DELETE_ON_DESTRUCTION, KEEP_ON_DESTRUCTION };
Bifilter(
Filter* _source = 0,
Filter* _sink = 0,
DestructorAction _action = KEEP_ON_DESTRUCTION
);
...
Now obviously DELETE_ON_DESTRUCTION is zero, which is a valid pointer
assignment, so I changed its declaration to
enum DestructorAction { DELETE_ON_DESTRUCTION=1, KEEP_ON_DESTRUCTION };
but still no error.
However, this
io::Bifilter _bif(new io::Device(_s2), 1);
does give the expected error:
test.cpp:36: error: invalid conversion from 'int' to 'Filter*'
test.cpp:36: error: initializing argument 2 of 'Bifilter::Bifilter(Filter*, Filter*,Bifilter::DestructorAction)'
Am I missing something (as usual!) or is this a bug?
Andrew Walrond