[Bug c++/85128] Local scope type(def) falsely assumed to change meaning of outer scope type(def)

steffen at sdaoden dot eu gcc-bugzilla@gcc.gnu.org
Tue Apr 3 14:25:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85128

--- Comment #12 from Steffen Nurpmeso <steffen at sdaoden dot eu> ---
  Or you could compile with -std=c++98

Yes, thanks for the opportunity.  I would rather not, the fix was simple and
only affected this class and its specializations (of 383, 315 public
interface).

  > (we had override, as a macro that expanded to virtual)

  Yuck.

But still thinking that is better than what has been standardized, since the
"const" suffix (i call it that way..) has to be given at the definition or you
have an error, doing the same for the other one is an error by itself!


#?0[steffen@essex tmp]$ cat t.cc
#include <stdio.h>
class A{
        char const *m_cp;
public:
        A(void):m_cp(NULL){}
        virtual ~A(void){}
        virtual char const *msg(void) const {return m_cp;}
};
class B : A{
public:
        char const *msg(void) const override;
};
char const *B::msg(void) const override {return "why-o-why";}
int
main(void){
        A o1;
        B o2;
        printf("o1=%s o2=%s\n", o1.msg(), o2.msg());
        return 0;
}
#?0[steffen@essex tmp]$ g++ -W -Wall -pedantic -o zt t.cc
t.cc:13:32: error: virt-specifiers in 'msg' not allowed outside a class
definition
 char const *B::msg(void) const override {return "why-o-why";}
                                ^~~~~~~~

Really, really yuck.  Imho.
Being explicit and not using tags or fully blown IDEs seems obsolete it seems,
i for one like documentation free sources and then

  _pub _ove TextWriter::~TextWriter(void){..

says this is public and overrides a virtual at glance.  Changes more for the
humans than the machines i would appreciate more.  (All imho, of course.)
Ciao.  Sorry for the noise, anyway, bug was on my side.


More information about the Gcc-bugs mailing list