gcc - Is there any way to force g++ to compile this program? -


making g++ compile things shouldn't isn't idea (and suspect not possible in general), in case i'm trying write static analysis checks find violations of specific misra rules , unfortunately g++ rather :) i'm trying check rule says "a pointer virtual base class shall cast pointer derived class means of dynamic_cast." such sensible rule g++ checks , fails compile following code:

class b { public:         virtual ~b() {} };  class d : public b {}; class vd : virtual public b {};  int main() {         d d;         vd vd;         b *pd = &d;         b *pvd = &vd;         d *d1 = (d*)(pd); // fine         d *d2 = static_cast<d*>(pd); // fine         d *d3 = dynamic_cast<d*>(pd); // fine         d& d4 = static_cast<d&>(*pd); // fine         d& d5 = dynamic_cast<d&>(*pd); // fine         vd *vd1 = (vd*)(pvd); // bad         vd *vd2 = static_cast<vd*>(pvd); // bad         vd *vd3 = dynamic_cast<vd*>(pvd); // fine         vd& vd4 = static_cast<vd&>(*pvd); // bad         vd& vd5 = dynamic_cast<vd&>(*pvd); // fine         return 0; } 

this makes me feel extremely positive using g++ compiler, bit problematic in case, because (a) have able build code in order analyse our tool, , (b) there may other compilers unhelpfully compile code, in case can't mark down "compiler-checked" in general.

short of trying find compiler compile (which option), there way of making g++ compile it? tried -fpermissive without success.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -