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

  • Home
  • SEARCH
  • 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 94647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:32:04+00:00 2026-05-10T23:32:04+00:00

[This is for PC/Visual C++ specifically (although any other answers would be quite illuminating

  • 0

[This is for PC/Visual C++ specifically (although any other answers would be quite illuminating :))]

How can you tell if a pointer comes from an object in the stack? For example:

int g_n = 0;  void F() {     int *pA = &s_n;     ASSERT_IS_POINTER_ON_STACK(pA);     int i = 0;     int *pB = &i;     ASSERT_IS_POINTER_ON_STACK(pB); } 

so only the second assert (pB) should trip. I’m thinking using some inline assembly to figure out if it’s within the SS segment register or something like that. Does anybody know if there’s any built in functions for this, or a simple way to do this?

Thanks! RC

  • 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. 2026-05-10T23:32:04+00:00Added an answer on May 10, 2026 at 11:32 pm

    Technically speaking, in portable C you can’t know. A stack for arguments is a hardware detail that is honored on many but not all compilers. Some compilers will use registers for arguments when they can (ie, fastcall).

    If you are working specifically on windows NT, you want to grab the Thread Execution Block from calling NtCurrentTeb(). Joe Duffy’s blog has information on this and from it you can get the stack range. You check for pointer in range and you should be good to go.

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

Sidebar

Related Questions

We get this error in Visual Studio 2005 and TFS very often. Can anyone
When using Visual Studio (though ideally this can apply to the generic case) and
I'm asking this specifically regarding Visual Studio 2008 and also the upcoming Visual Studio
More specifically, what do I need to know about doing this in Visual Studio
I was wondering if there is any feature in Visual Studio 2008 that would
I am using a library that has headers without the .h This defeats visual
If I am debugging (in this case a Visual Studio assembly called by Excel)
What library should be included to use TransparentBlt? This is VC98 (Visual Studio 6)
This is Crystal Reports 9 in Visual Studio 2003 by the way Simple question
I installed Visual Studio (Web Developer in this case) Express Edition and was reading

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.