473,803 Members | 3,899 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

stack

jt
hello everyone..

int fun()
{
/* anything */
}
int main(void)
{
fun();
}

in this program, when the control is transferred to function fun()..
the return address is pushed to the stack..
Is it possible to access this value..??
Aug 3 '08
62 2880
Harold Aptroot wrote:
"MisterE" <Mi*****@nimga. comwrote in message
>>Is it possible to access this value..??

No.

Of course it is. The OP did not request a standard compliant
way to do it after all
On this newsgroup, there are no non-standard compliant ways to do
anything. Anything of that nature is off=topic, and may be found
on specialized news-groups dealing with the authors system.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.
Aug 4 '08 #21
On Mon, 04 Aug 2008 17:42:31 -0400, CBFalconer wrote:
Harold Aptroot wrote:
>"MisterE" <Mi*****@nimga. comwrote in message
>>>Is it possible to access this value..??

No.

Of course it is. The OP did not request a standard compliant way to do
it after all

On this newsgroup, there are no non-standard compliant ways to do
anything. Anything of that nature is off=topic,
Please don't use topicality as an excuse or defence for lies. I don't know
if MisterE is aware of the existence of any non-portable methods of
accessing a function call's return address, but you are.
Aug 4 '08 #22
CBFalconer <cb********@yah oo.comwrites:
Harold Aptroot wrote:
>"MisterE" <Mi*****@nimga. comwrote in message
>>>Is it possible to access this value..??

No.

Of course it is. The OP did not request a standard compliant
way to do it after all

On this newsgroup, there are no non-standard compliant ways to do
anything. Anything of that nature is off=topic, and may be found
on specialized news-groups dealing with the authors system.
Dont be such a prissy twit. If people want help in a C related area and
it happens that someone here can help it would be ludicrous not to.
Aug 4 '08 #23
CBFalconer <cb********@yah oo.comwrites:
Harold Aptroot wrote:
>"MisterE" <Mi*****@nimga. comwrote in message
>>>Is it possible to access this value..??

No.

Of course it is. The OP did not request a standard compliant
way to do it after all

On this newsgroup, there are no non-standard compliant ways to do
anything. Anything of that nature is off=topic, and may be found
on specialized news-groups dealing with the authors system.
The question was "Is it possible to access this value..??" (namely the
return address for a function). Either "Yes, but it's
system-specific", or "There's no portable way to do it" would be a
correct answer (though the latter is incomplete).

An unqualified "No." is not a correct answer.

People who post off-topic questions should not be punished by being
fed false information. And for that matter, the question itself
wasn't off-topic, though a detailed answer without a redirection would
have been.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Aug 5 '08 #24
In article <ln************ @nuthaus.mib.or g>,
Keith Thompson <ks***@mib.orgw rote:
>The question was "Is it possible to access this value..??" (namely the
return address for a function). Either "Yes, but it's
system-specific", or "There's no portable way to do it" would be a
correct answer (though the latter is incomplete).
"Yes, but it's system-specific" is incorrect. On some systems
there is no mechanism to get at the return address.
"There's no portable way to do it" is correct, as it includes
the case of there being no way to do it on some systems.
--
"You may comand nature to the extent only in which you are willing to
obey her." -- Walter Russell
Aug 5 '08 #25
Keith Thompson wrote:
CBFalconer <cb********@yah oo.comwrites:
.... snip ...
>
>On this newsgroup, there are no non-standard compliant ways to do
anything. Anything of that nature is off=topic, and may be found
on specialized news-groups dealing with the authors system.
.... snip ...
>
People who post off-topic questions should not be punished by
being fed false information. And for that matter, the question
itself wasn't off-topic, though a detailed answer without a
redirection would have been.
I don't think I did 'punish'. I told him where to go, in general
terms. He didn't specify his system.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.
Aug 5 '08 #26
On 4 Aug, 23:25, Harald van D©¦k <true...@gmail. comwrote:
On Mon, 04 Aug 2008 17:42:31 -0400, CBFalconer wrote:
Harold Aptroot wrote:
"MisterE" <Mist...@nimga. comwrote in message
>>Is it possible to access [the return address] value..??
>No.
Of course it is. The OP did not request a standard compliant way to do
it after all
On this newsgroup, there are no non-standard compliant ways to do
anything. Anything of that nature is off=topic,

Please don't use topicality as an excuse or defence for lies.
its not a lie. It's a fact. Your statement is incorrect. There
*is* no standard way to do this and since the topic of this NG
is standard C there is no way to do it that is topical to this
NG. Though I must admit I'd have suggested trying another NG.
I don't know
if MisterE is aware of the existence of any non-portable methods of
accessing a function call's return address, but you are.

--
Nick Keighley

"computers are no longer intended for those who can
understand mathematics, but only for those who cannot."
Herman Rubin (comp.lang.c)
Aug 5 '08 #27
On 4 Aug, 22:30, CBFalconer <cbfalco...@yah oo.comwrote:
jt wrote:
int fun() {
/* anything */
}
int main(void) {
fun();
}
in this program, when the control is transferred to function fun()..
the return address is pushed to the stack..
Is it possible to access this value..??

In a machine that can execute the standard C language, there is no
need for a stack. This makes it hard to access a return address
(of unknown form) stored in a non-existant stack.
but the information must be stored *somewhere* otherwise
the implementation wouldn't be able to return from the function.
Admittedly the implementaion is under no obligation to make
it available to the user.
--
Nick Keighley

This is not the same as a proof of correctness,
but proofs of correctness can only be constructed by computer
scientists with fancy degrees, not by mere clever programmers.
Ben Pfaff
Aug 5 '08 #28
Nick Keighley wrote:
On 4 Aug, 22:30, CBFalconer <cbfalco...@yah oo.comwrote:
>jt wrote:
int fun() {
/* anything */
}
int main(void) {
fun();
}
in this program, when the control is transferred to function fun()..
the return address is pushed to the stack..
Is it possible to access this value..??

In a machine that can execute the standard C language, there is no
need for a stack. This makes it hard to access a return address
(of unknown form) stored in a non-existant stack.

but the information must be stored *somewhere* otherwise
the implementation wouldn't be able to return from the function.
Admittedly the implementaion is under no obligation to make
it available to the user.
In the program above, if the compiler chose to inline `fun`, the
"return address" would be "stored" by the implicit fall-through of
one instruction to the next [1].

As we have discussed before, not all C programs need an explicit
run-time stack data-structure. Of those that do, that structure
need not correspond to the local hardware's notion of "stack",
if it has one. Even if it does, the implementation is under no
requirement of the C standard to expose that stack to C programs.

And even if it /does/, mere ability should not elicit reckless
employment. One can, after all, clean one's teeth with a
screwdriver.

[1] On an implementation that uses "instructio ns", of course.

--
'It changed the future .. and it changed us.' /Babylon 5/

Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN

Aug 5 '08 #29
Nick Keighley wrote:
On 4 Aug, 22:30, CBFalconer <cbfalco...@yah oo.comwrote:
>jt wrote:
int fun() {
/* anything */
}
int main(void) {
fun();
}
in this program, when the control is transferred to function
fun().. the return address is pushed to the stack..
Is it possible to access this value..??

In a machine that can execute the standard C language, there is no
need for a stack. This makes it hard to access a return address
(of unknown form) stored in a non-existant stack.

but the information must be stored *somewhere* otherwise
the implementation wouldn't be able to return from the function.
And it must also *behave* like a LIFO data structure. So at least a
software based stack is necessary.

Aug 5 '08 #30

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
7745
by: Andrew | last post by:
Last night I was reading about implementing my own stack. The example given pushes items on and off the stack at the start and end of each procedure (ie. in a std module). What's not so clear is how this would work with class objects. In this case do you have to push the object on the stack at the start of every public procedure etc. in the class and pop it off at the end? I can't see how else you can know which object is active - or...
14
30102
by: Kevin Grigorenko | last post by:
Hello, I couldn't find an obvious answer to this in the FAQ. My basic question, is: Is there any difference in allocating on the heap versus the stack? If heap or stack implementation is not part of the standard, then just disregard this question. Here's some questions I'm confused about, and if you can add anything else, please do so! Is the stack limited for each program?
4
2624
by: Chris Mabee | last post by:
Hello all, and Merry Christmas, I'm having a problem understanding an example of an array based implementation of a stack in a textbook of mine. The code in question is written below. The syntax is directly as in the book, except for where I added the comments at the lines I wanted to refer to or to skip sections of code. template <class Element_Type> class Stack {
4
3631
by: anonymous | last post by:
Thanks your reply. The article I read is from www.hakin9.org/en/attachments/stackoverflow_en.pdf. And you're right. I don't know it very clearly. And that's why I want to understand it; for it's useful to help me to solve some basic problem which I may not perceive before. I appreciate your help, sincerely.
8
2100
by: LedZep | last post by:
What up everyone, I have to write a program that uses a stack to determine whether a string is a palindrome (a string that is spelled identically backward and forward). The program has to ignore spaces, case sensitivity and punctuation. I need three text boxes. The first will be for input of the string. The second will display the string when the "check" button is clicked and the result of the analysis (string is a palindrome or is...
4
2150
by: alisaee | last post by:
plz check what i have made wrong what is requierd her is to creat class queue and class stack and run the push,pop operation . #include<iostream.h> #include<conio.h> #include<stdio.h> class stack { public:
16
4451
by: sarathy | last post by:
Hi all, I need a few clarifications regarding memory allocaion in C++. I apologize for the lengthy explanation. 1. In C++, Objects are allocated in heap. What does heap refer to? Is it an area in RAM/Memory or does it refer to a data structure being used for storing objects. 2. In C++, functions and its local variables go in stack. If local variables that are primitives go in stack, it is OK. But what
24
6592
by: John | last post by:
I know this is a very fundamental question. I am still quite confused if the program call stack stack should always grows upwards from the bottom, or the opposite, or doesn't matter?? That means the stack pointer should go upwards when there are "push" operations, and stack pointer should go downards when there are "pop" operations?? If this is the case, the address should go upwards (increasing) or downards (decreasing) then? i.e....
1
4223
by: alfie27 | last post by:
I currently have a working program that is a stack that stores integers. Now i have to convert it to store strings instead of integers. I have been working on this for hours and just keep getting errors of all kinds. I have decided to start from scratch. Any suggestions someone can give me would be greatly appreciated!! Here is the current code: #include <iostream> using std::cout; using std::cin; #include <cstring> using std::strcpy;
11
1788
by: tom | last post by:
Hi! Im new to Python and doing exercise found from internet. It is supposed to evaluate expression given with postfix operator using Stack() class. class Stack: def __init__(self): self.items = def push(self, item): self.items.append(item)
0
9700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9121
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7603
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6841
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.