dascandy / hippomocks

GNU Lesser General Public License v2.1
196 stars 67 forks source link

Compilation error MSVC 2015 #55

Closed farnyser closed 8 years ago

farnyser commented 8 years ago

Hello,

I'm trying to use HipoMocks but it seems to be broken on VS2015

class ID {
public:
    virtual ~ID() {};
    virtual int f();
    virtual std::string g() = 0;
};

BOOST_AUTO_TEST_CASE(MyTest)
{
    MockRepository mocks;
    ID *iamock = mocks.Mock<ID>();
    mocks.ExpectCall(iamock, ID::f).Return(1);
    mocks.ExpectCall(iamock, ID::g).Return("fsck");
    BOOST_CHECK(iamock->f() == 1);
    BOOST_CHECK(iamock->g() == "fsck");
}

Error message:

hippomocks.h(1245): error C4700: uninitialized local variable 'conv' used

This is the code:

    if (value != -1)
        return std::pair<int, int>((int)(conv.u.baseoffs/sizeof(void*)), value);
dascandy commented 8 years ago

That's surprising, since as far as I know conv is a union specifically to do this kind of conversion. Let me check tonight when I have access to a Windows machine again.

dascandy commented 8 years ago

Found the cause. Should be fixed now; can you check on the cpp11 branch? Please reopen if it is still there.