niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » *nix » SGI/IRIX » apps
MIPSPro compiler sizeof classes
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
Author Message
philparsonage@hotmail.com
*nix forums beginner


Joined: 28 Jun 2006
Posts: 2

PostPosted: Wed Jun 28, 2006 2:00 pm    Post subject: MIPSPro compiler sizeof classes Reply with 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
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

PostPosted: Wed Jun 28, 2006 5:50 pm    Post subject: Re: MIPSPro compiler sizeof classes Reply with quote

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

PostPosted: Thu Jun 29, 2006 8:43 am    Post subject: Re: MIPSPro compiler sizeof classes Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
The time now is Tue Dec 02, 2008 1:35 pm | All times are GMT
navigation Forum index » *nix » SGI/IRIX » apps
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Anyone interested in a 4gl compiler ? Mike Aubury MySQL 1 Fri Jul 21, 2006 1:53 pm
No new posts How to use Sun C Compiler in place of gcc? Richard B. Gilbert Solaris 6 Thu Jul 20, 2006 9:43 pm
No new posts again a newbie... :( compiler problems Thorsten Kaben C++ 18 Thu Jul 20, 2006 2:52 am
No new posts Warning when new attributes are added to classes at run time Matthew Wilson python 7 Wed Jul 19, 2006 8:42 pm
No new posts sizeof() junw2000@gmail.com C++ 5 Wed Jul 19, 2006 3:56 pm

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
[ Time: 0.4827s ][ Queries: 16 (0.3537s) ][ GZIP on - Debug on ]