Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++ Subject: Re: Has "stack overflow" specified behavior? Date: Thu, 16 Dec 2021 14:15:38 -0800 Organization: None to speak of Lines: 35 Message-ID: <871r2c8ad1.fsf@nosuchdomain.example.com> References: <86czm05exm.fsf@linuxsc.com> <86a6h04pwl.fsf@linuxsc.com> <0f0a9266-6f5c-40a8-abe7-83b771f64395n@googlegroups.com> <87ilvo8fue.fsf@nosuchdomain.example.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="20ffafaec83dfe7e814f2bd671a6cef3"; logging-data="4691"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/yumy7eFh5c/WUIYgJlI87" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:qwtzPCBfPqUpcQ+EZ3ACMeoYCic= sha1:7KrWr0a6FvQLYsXqipHDvgZdqD0= Xref: csiph.com comp.lang.c++:82667 wij writes: > On Friday, 17 December 2021 at 04:17:31 UTC+8, Keith Thompson wrote: >> wij writes: >> [...] >> > By the way, I though the 'stack' still must exist no matter how it is >> > implemented. Because the process of RAII/function call and the >> > 'auto' (old name) variables are mostly efficient in the stack. >> > These all added to be most efficient in one stack (or 'primary stack'). >> It depends on what you mean by "stack". >> >> Most C++ implementations use a "stack" in the sense of a contiguous >> region of memory managed via a pointer to the "top". >> >> A contiguous memory "stack" (which is not required by the standard) is >> the most common way to implement the abstract last-in first-out >> semantics of function calls. There are implementations (at least for C, >> and probably for C++) that do something similar to a malloc call to >> allocate storage for a new function call. > > If so, something should still be remained in the main stack for the > tracking to work. Each function can have its own stack, that stack can > be reallocated, but the address value can't change. In all, these > maneuvers are opaque to the user. The user code just don't assume the > amount of stack space acquired is the whole thing. Nothing too > significantly changes from the user's point of view. IOW, getting the > amount of stack space (from API) seems still significant, just not > common. As I said, there are (at least) two very different meanings of the word "stack". I can't tell which one you're using here. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Philips void Void(void) { Void(); } /* The recursive call of the void */