Bug 55367 - Probably problem with c++ vptr under templates and multiple inheritance
Summary: Probably problem with c++ vptr under templates and multiple inheritance
Status: RESOLVED DUPLICATE of bug 55171
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 55453 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-11-17 16:21 UTC by walid riabi
Modified: 2012-11-24 11:52 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
code snippet (455 bytes, text/plain)
2012-11-17 16:21 UTC, walid riabi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description walid riabi 2012-11-17 16:21:55 UTC
Created attachment 28720 [details]
code snippet

Hello,
I have some code that compile and work fine in gcc 4.6.2 (without tne new keyword "override" ) but in version 4.7.2 it complie generate access violation runtime. under windows platform.

So, i need some help, thank you very much:

#include <iostream>
using namespace std;
 
struct Entity {
    //~Entity() = default; //work fine
    ~Entity() {} //when i specified my destructor this compile but generate runtime access viloation
};
 
template<typename T>
struct IRepository { virtual T g() = 0; };
 
struct OtherInterface{ virtual void y() = 0; };
 
struct IEntityRepository : public virtual IRepository<Entity>{ };
 
template<typename T>
struct RepositoryBase : public virtual IRepository<T>, public OtherInterface{
    virtual void y()  override { cout << "y() override called" << endl; }
};
 
template<typename T>
struct DataRepository : public RepositoryBase<T>{
    virtual T f() { cout << "f() called" << endl; this->y(); T t; return t; }
        T g() override {
        cout << "g() override called" << endl;
        ////when i specified my destructor for class Entity this compile but generate runtime access viloation here : on this: probably problem with vptr
        return this->f(); }
};
 
struct EffectiveEntityRepository : public DataRepository<Entity>, public IEntityRepository{
};
 
int main() {
    IEntityRepository* var = new EffectiveEntityRepository();
    var->g();
    return 1;
}
Comment 1 Paolo Carlini 2012-11-18 14:04:00 UTC
Does it happen only on Windows? Which kind of system exactly, mingw, Cygwin? In case should be <target>, as Component
Comment 2 walid riabi 2012-11-18 19:41:00 UTC
I just tried that with the latest version (4.7.2) of MingW under windows 8
Comment 3 walid riabi 2012-11-18 19:43:25 UTC
I just tried that with the latest version (4.7.2) of MingW under windows 8
Comment 4 Pawel Sikora 2012-11-18 19:46:59 UTC
looks like PR55171
Comment 5 Paolo Carlini 2012-11-18 21:05:23 UTC
Indeed it does, but we badly need a mingw maintainer to resolve this (or these) issues
Comment 6 walid riabi 2012-11-19 19:48:12 UTC
I'm a candidate:)
Comment 7 Paolo Carlini 2012-11-23 21:51:10 UTC
*** Bug 55453 has been marked as a duplicate of this bug. ***
Comment 8 Paolo Carlini 2012-11-23 21:57:11 UTC
Dup.

*** This bug has been marked as a duplicate of bug 55171 ***
Comment 9 Kai Tietz 2012-11-24 11:52:24 UTC
(In reply to comment #8)
> Dup.
> 
> *** This bug has been marked as a duplicate of bug 55171 ***

Hmm, indeed a dup.  It seems to be related to the thunk-code for thiscall.  I will take a look to it.