-Wignored-qualifiers, a rock and a hard place

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.

I have inherited a whole heap of interfaces that, in principle, look like

class Base {
public:
  virtual ~Base() { }
  virtual const int method() = 0;
};

and the knowledge that there are many users of this code, similar to

class Derived : public Base {
public:
  const int method() { /* Do something */ return 0; }
};

Now, I think -Wignored-qualifiers i a relly nice debug option so I compile
the above code and - as expected - I get warnings:

warning: type qualifiers ignored on function return type [-Wignored-qualifiers]

for the 'const int'. Now that is quite reasonable so now I want to fix the code
that I control, i.e. only Base. (Ok, I would like to fix all Derived's as
well but right now that is impossible as I don't even know where they all are).

Since the warning says the type qualifier is ignored I would guess that I could
just remove it in Base but when I change Base to

class Base {
public:
  virtual ~Base() { }
  virtual int method() = 0;
};

and recompiles I end up with

warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
error: conflicting return type specified for 'virtual const int Derived::method()'
error:   overriding 'virtual int Base::method()'

so obviously the const ain't that ignored after all.

Now, my question is how I can remove that const in an incremental way so that
I don't have to use a flag day but can shift all of those 6000 warnings down
to the not yet updated uses in the Derived instances.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux