From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,d275ffeffdf83655 X-Google-Attributes: gid109fba,public X-Google-Thread: f5d71,d275ffeffdf83655 X-Google-Attributes: gidf5d71,public X-Google-Thread: 146b77,d275ffeffdf83655 X-Google-Attributes: gid146b77,public X-Google-Thread: 103376,d275ffeffdf83655 X-Google-Attributes: gid103376,public From: robert_dewar@my-dejanews.com Subject: Re: Ada vs C++ vs Java Date: 1999/01/18 Message-ID: <77vim7$oog$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 433991511 References: <369C1F31.AE5AF7EF@concentric.net> <369DDDC3.FDE09999@sea.ericsson.se> <369e309a.32671759@news.demon.co.uk> <369F0592.94F9DDDA@dresdner-bank.com> <77pnr4$ch3$1@newnews.global.net.uk> <36a3281a.11980677@news.demon.co.uk> X-Http-Proxy: 1.0 x7.dejanews.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Mon Jan 18 15:06:55 1999 GMT Newsgroups: comp.lang.ada,comp.lang.c++,comp.vxworks,comp.lang.java X-Http-User-Agent: Mozilla/4.04 [en] (OS/2; I) Date: 1999-01-18T00:00:00+00:00 List-Id: In article <36a3281a.11980677@news.demon.co.uk>, johnb@invision.co.uk wrote: > If Complex is a class with an overloaded + operator, I > get temporary objects generated (possibly at the > compiler's option) in the above statement. > Now where do these temporary objects get created? On the > stack, or on the heap. It is hard to imagine a compiler so incompetent as to generate such temporaries on the heap. Of course there is no guarantee of this from the standard, which is not at this kind of implementation level. > > In C the stack size (without recursion) can never grow > beyond the maximum of the total of the stack requirements > of all of the functions defined. That is of course true in C++ (and for that matter all stack based languages) as well. > How do I calculate the potential stack size in C++? The same way you do in C, you have to find out how much stack each function is using. I hope you don't think that in C you can know this at the source level by looking at the number of local variables. It is hard to believe that any programmer would be so oblivious of what is going on at code generation time to believe this, but apparently you do from what you right. There are many reasons a C compiler might generate temporary locations on the stack, e.g. for register spill. You have to either read the assembly language to see what the compiler is generating, or use some tool to get this information. Getting the information from the source program is not possible for C or C++. > There is inherent dynamic memory allocation going on > here, it is irrelevant whether it is satck or heap. I > (the coder) did not explicitly allocate memory, the > language (or rather the implementation of the language) > did. You have a model of computation that is just plain wrong, probably because you don't know enough about computer architecture. (start of plug) A good reference for you might be my book on Microprocessors, since this addressed to programmers. McGraw Hill, 1990, "Microprocessors: A Programmer's View" Look for the soft cover version, the hard cover version is out of print (end of plug) -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own