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

Reply via email to