Discussion:
MIPSPro compiler sizeof classes
(too old to reply)
p***@hotmail.com
2006-06-28 14:00:09 UTC
Permalink
I'm having some trouble with the MIPSPro compiler, version 7.4.2m, on
an Octane MXE. I've posted a condensed code sample that shows my
problem. On every other compiler, sizeof(Test<unsigned char, float> is
(correctly) 3. On MIPSPro, it's 5! Basically it adds one for every
empty base class that Test inherits from. I can understand that
TestRGBBase can't have size 0, but it shouldn't affect the size of the
derived class should it?

Is this a known bug?

Is 7.4.2m the latest version of the compiler, and if not, where can I
get the latest?


#include <string>

class TestRGBBase {
public :
static const int testBase = 0;
};

class TestRGBBase2 {
public :
static const int testBase2 = 0;
};

template<class VALUETYPE, class ARITHMETICTYPE>
class Test : public TestRGBBase, public TestRGBBase2 {
public :
typedef VALUETYPE ValueType;
typedef ARITHMETICTYPE ArithmeticType;
VALUETYPE r, g, b;
};


int main(int argc, char *argv[])
{
Test<unsigned char, float> a;
TestRGBBase b;
TestRGBBase2 c;
printf("Size of Test is %d\n", sizeof(a));
printf("Size of TestRGBBase is %d\n", sizeof(b));
printf("Size of TestRGBBase2 is %d\n", sizeof(c));
}
Herve Boulouis
2006-06-28 17:50:42 UTC
Permalink
Post by p***@hotmail.com
I'm having some trouble with the MIPSPro compiler, version 7.4.2m, on
an Octane MXE. I've posted a condensed code sample that shows my
problem. On every other compiler, sizeof(Test<unsigned char, float> is
(correctly) 3. On MIPSPro, it's 5! Basically it adds one for every
This is completely compiler/platform dependent and you can't expect it to be
constant across different environments.
--
Herve Boulouis - Nerim
p***@hotmail.com
2006-06-29 08:43:58 UTC
Permalink
Post by Herve Boulouis
This is completely compiler/platform dependent and you can't expect it to be
constant across different environments.
Thanks for the reply - I understand what your saying, but this works
across every operating system/compiler combination that we work with -
g++ on Mac, Linux, IRIX and Windows, MSVC on Windows, Codewarrior on
Mac<snip>.........apart from MIPSPRO. Anyone out there got any ideas on
what the C++ standard says? I've had a look, but I find that document
might as well be written in a foreign language for all I understand it.
Loading...