Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Is Stack Smashing Code standard?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
DK  
View profile  
 More options Jan 12 2007, 4:33 am
Newsgroups: gnu.gcc.help
From: "DK" <divyekap...@gmail.com>
Date: 12 Jan 2007 01:33:28 -0800
Local: Fri, Jan 12 2007 4:33 am
Subject: Is Stack Smashing Code standard?
The following program gives the output as the last initialized variable
in the function func. Is this type of code behaviour standard or just a
gcc quirk?

#include <iostream>
using namespace std;
int func(int);
int main() {
   int n = func(2);
   cout << n << endl;
   return 0;

}

int func(int a) {
   int b = a*a;
   int c = b*b;

}

Output: 16
Thanks in advance.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jacob navia  
View profile  
 More options Jan 12 2007, 6:25 am
Newsgroups: gnu.gcc.help
From: jacob navia <ja...@jacob.remcomp.fr>
Date: Fri, 12 Jan 2007 12:25:26 +0100
Local: Fri, Jan 12 2007 6:25 am
Subject: Re: Is Stack Smashing Code standard?
DK a écrit :

This is undefined behavior. You fail to specify the return value.
Anything can happen, including (but not limited to)
returning the last value used.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul Pluzhnikov  
View profile  
 More options Jan 12 2007, 9:52 am
Newsgroups: gnu.gcc.help
From: Paul Pluzhnikov <ppluzhnikov-...@charter.net>
Date: Fri, 12 Jan 2007 06:52:18 -0800
Local: Fri, Jan 12 2007 9:52 am
Subject: Re: Is Stack Smashing Code standard?

jacob navia <ja...@jacob.remcomp.fr> writes:
> DK a écrit :
>> The following program gives the output as the last initialized variable
>> in the function func.

For some platforms and some versions of gcc and some compilation
options:

# Linux/x86
$ g++ -g junk.cc && ./a.out
16
$ g++ -g junk.cc -O && ./a.out
0

# Solaris/SPARC
$ g++ -g junk.cc  && ./a.out
16
$ g++ -g junk.cc -O && ./a.out
2

> Anything can happen, including (but not limited to)
> returning the last value used.

And (as above) anything *does* happen ...

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google