Operating System - Linux
1751695 Members
5060 Online
108781 Solutions
New Discussion юеВ

Re: aCC version and ANSI compliance

 
justaprogrammer
Occasional Contributor

aCC version and ANSI compliance

I am using aCC version B3910B A.03.50 and got a stack corruption at run time. It seems that the culprit is a whole lot of "char varname[5001];", which would assign space on the stack. I sorted the problem with string's (they use the heap). It seems to me that the stack size is being set, and not adjusted by the compiler (isn't this sensible). How do I find the default stack size and how do I change it (if need be).
I wish to know what the above compiler version means (I am using hpux11.11 9000/800 PA_RISK Version 2.)
In a more general mode: what is the level of compliance of differnt compiler versions with the ANSI standard.

Thanks
David
4 REPLIES 4
A. Clay Stephenson
Acclaimed Contributor

Re: aCC version and ANSI compliance

The stack size has nothing to do with the compiler --- and, it should never be. If it were and programmer's had their way then the stack size would approach infinity --- which would lead to even more bad code. The maximum size of the stack is determined at run-time and is actually limited in two different ways and the smaller always wins.
First, the kernel tunable maxssiz (and if a 64-bit executable maxssiz_64bit) this defaults to 8MiB and only VERY poorly written code would ever require a stack larger than 64MiB and I generally set it to 32MiB for both 32-bit and 64-bit executables. The second limit is ulimit -s value.

You can find your current stack size by "ulimit -s".

For your last question, I would say read the documentation.
If it ain't broke, I can fix that.
Dennis Handly
Acclaimed Contributor

Re: aCC version and ANSI compliance

Stack corruption is different than stack overflow. Which did you get?

As Clay mentioned, the size is limited by maxssiz. Unless you are using threads.

Instead of using strings, you may want to use
char *p= new char[5001];
Of course you need to delete before returning.

A.03.50 is 3 years old and the latest version is A.03.70. A reference to the C++ Standards is on:
http://www.docs.hp.com/en/7762/5991-4874/standards.htm#stdunsup

>Clay: The stack size has nothing to do with the compiler.

While the compiler doesn't control the total size, the compiler can create giant frames by excessive inlining. And in a threaded environment, the stack is limited to 64 Kb default.
A. Clay Stephenson
Acclaimed Contributor

Re: aCC version and ANSI compliance

Well, if we are talking about threads (which isn't obvious in the original question) then obviously each thread has its own stack which, as mentioned, on HP-UX defaults to 64KiB but can be overridden to a different value then pthread_create() is called --- so long as the total of all this does not exceed maxssiz.
If it ain't broke, I can fix that.
Dennis Handly
Acclaimed Contributor

Re: aCC version and ANSI compliance

>Clay: so long as the total of all this does not exceed maxssiz.

The thread stacks are allocated in the heap or mmaps, so maxssiz has nothing to do with them.