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 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

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
How can I specifically set up Visual Studio 2010 so I can automatically change
I realise this is a silly question but the MSDN can't be accessed from
I have compiled this using Visual Studio 2010 compiler and it has compiler error
This has happened since yesterday, some razor views display like this in visual studio:
Does anyone know the equivalent for doing this in Visual Studio 2008( EnvDTE90 )
Let's assume this scenario in Visual C++ 2010: #include <iostream> using namespace std; struct
I've been seeing this in my Visual C# 2008 RSS Feed forever now: http://lincolnfair.net/oldLincolnFair/mad.jpg
When I type this into the Visual Studio 2008 immediate window: ? .9 -

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.