Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7944319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:31:02+00:00 2026-06-04T00:31:02+00:00

I was trying to call a function that was allocated in the heap. After

  • 0

I was trying to call a function that was allocated in the heap. After some failed attempts I tried the code in this website:

http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/85d5da8c-edef-44b0-b42e-deb5f3eb2524

The code works flawlessly. It compiles, run, give the correct/expected result and finishes with no problem.

However if I try adding something like std::cout << “Hello World!” << std::endl in the function, copy it to the heap and then execute the heap function it just doesn’t work. If there’s a cout there it don’t work, without the cout it works.

I would like to know why this happens, and how can I solve this problem. Realize that I am doing this with the only purpose of learning, I have no interest in applying this to the practical usage.

If I the heap function calls a function that uses std::cout to print data, that code doesn’t work either.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:31:04+00:00Added an answer on June 4, 2026 at 12:31 am

    Your problem lies with the fact that when you add the cout code to the function you essentially add some function calls. Microsoft C/C++ compiler uses some basic stack frame checking for detection of problems in runtime. Those checks are performed by calling the __RTC_CheckEsp function after each function call. The call to __RTC_CheckEsp uses the E8 opcode which means relative addressing. When the sample function is moved to the heap, the call to __RTC_CheckEsp becomes erroneous since it jumps to the wrong location.

    Disable the runtime stack frame checking (in Visual Studio 2010): Project options -> Configuration Properties -> C/C++ -> Code Generation -> Basic Runtime Checks -> set it to Uninitialized Variables

    Recompile. Run. Enjoy!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to call a function that contains jQuery code. I want this function
I am trying to create a function that sends 100 call per second, and
In my javascript function I am trying to call my global variable that is
GCC seem to think that I am trying to make a function call in
Im trying to return the value that a $ajax call returns, from a function
I am trying to call my function named isUrgencyTypeValid from my javascript code but
I've got some inherited code that went something like this. (Please hold the laughter...
I am trying to call a function that, on the load of the script
Trying to call lang() function that is part of codeigniter's system/helpers (language_helper.php), resulting in
I am trying to figure out what you call a function that references itself.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.