www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18616] New: attrib.h:31:7: warning: 'AttribDeclaration' has


          Issue ID: 18616
           Summary: attrib.h:31:7: warning: 'AttribDeclaration' has
                    virtual functions but non-virtual destructor
           Product: D
           Version: D2
          Hardware: x86
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: timothee.cour2 gmail.com

when compiling calypso (but dmd has same issue) i get:

../ddmd/attrib.h:31:7: warning: 'AttribDeclaration' has virtual functions but
non-virtual destructor [-Wnon-virtual-dtor]

indeed this is what's in src/dmd/attrib.h: it shows virtual functions but
non-virtual destructor;

* won't that result in memory leaks?

* should we add `-Wnon-virtual-dtor` to detect these?

* this type of error occurs in lots of places

class AttribDeclaration : public Dsymbol
    Dsymbols *decl;     // array of Dsymbol's

    virtual Dsymbols *include(Scope *sc);
    int apply(Dsymbol_apply_ft_t fp, void *param);
    static Scope *createNewScope(Scope *sc,
        StorageClass newstc, LINK linkage, CPPMANGLE cppmangle, Prot
        int explicitProtection, AlignDeclaration *aligndecl, PINLINE inlining);
    virtual Scope *newScope(Scope *sc);
    void addMember(Scope *sc, ScopeDsymbol *sds);
    void setScope(Scope *sc);
    void importAll(Scope *sc);
    void addComment(const utf8_t *comment);
    const char *kind() const;
    bool oneMember(Dsymbol **ps, Identifier *ident);
    void setFieldOffset(AggregateDeclaration *ad, unsigned *poffset, bool
    bool hasPointers();
    bool hasStaticCtorOrDtor();
    void checkCtorConstInit();
    void addLocalClass(ClassDeclarations *);
    AttribDeclaration *isAttribDeclaration() { return this; }

    void accept(Visitor *v) { v->visit(this); }


Mar 14 2018