|
|
|
|
|
|
| Author |
Message |
philparsonage@hotmail.com *nix forums beginner
Joined: 28 Jun 2006
Posts: 2
|
Posted: Wed Jun 28, 2006 2:00 pm Post subject:
MIPSPro compiler sizeof classes
|
|
|
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));
} |
|
| Back to top |
|
 |
Herve Boulouis *nix forums beginner
Joined: 09 Jun 2005
Posts: 10
|
Posted: Wed Jun 28, 2006 5:50 pm Post subject:
Re: MIPSPro compiler sizeof classes
|
|
|
On 2006-06-28, philparsonage@hotmail.com <philparsonage@hotmail.com> wrote:
| Quote: | 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 |
|
| Back to top |
|
 |
philparsonage@hotmail.com *nix forums beginner
Joined: 28 Jun 2006
Posts: 2
|
Posted: Thu Jun 29, 2006 8:43 am Post subject:
Re: MIPSPro compiler sizeof classes
|
|
|
Herve Boulouis wrote:
| Quote: | 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. |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Tue Dec 02, 2008 1:35 pm | All times are GMT
|
|
Peak Oil | Free Mmorpg | Stag Weekends | Books | Car Credit
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|