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 4092694
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:31:25+00:00 2026-05-20T19:31:25+00:00

Ok this must be something dumb. I ran into this when moving some code

  • 0

Ok this must be something dumb. I ran into this when moving some code over and figured I had made a typo or was failing to use the debugger correctly. As a sanity check I created this test case but it still appears to be failing.

    unsigned int  vtxIdx = 0;
    unsigned int* tgtIdx;

    NSLog(@"Init %d", vtxIdx);

    tgtIdx = &vtxIdx;

    NSLog(@"After %d", vtxIdx);

    float* pVtx = new float[1000*3];

    NSLog(@"After more %d", vtxIdx);

Output:

2011-03-24 09:59:23.494 Game-iOS[] Init 0
2011-03-24 09:59:25.677 Game-iOS[] After 4
2011-03-24 09:59:31.828 Game-iOS[] After more 12

Edit:

What initially tipped me off was I was seeing weird values in the XCode variable window. So I don’t think it is an NSLog issue as I see those same value in XCode. Watching vtxIdx in the debugger it appears to increase by 4 with each instruction.

All of this code is in an .mm files if that matters.

  • 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-05-20T19:31:26+00:00Added an answer on May 20, 2026 at 7:31 pm

    For your second output statement, do you get the same thing if you print the values of both vtxIdx and *tgtIdx?

    Does anything change if you initialize tgtIdx = NULL;?

    If you run each NSLog function twice in a row with the exact same arguments, do they output the same thing each time?

    You mentioned a debugger in your question. What did you see when you single-stepped through this program?

    Edit:
    A few more ideas.

    What happens if you comment out the tgtIdx = &vtxIdx; line?

    What happens if you add the line unsigned int dummy; before your existing variable declarations?

    Since something seems to be changing the variable behind your back, my first thoughts are a memory corruption issue (some other code is writing over your variable unintentionally) or a linkage problem (the linker saw your variable and another variable with the same name, thought they were the same object, and merged them together). Adding the dummy variable declaration should help indicate if the problem is a memory corruption problem, and renaming the variables should test for any possible name resolution conflicts.

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

Sidebar

Related Questions

I know SQL well but I must be missing something really dumb here. This
Something must be wrong with this code right here: + (UIImage*)captureView:(UIView *)theView { UIGraphicsBeginImageContext(theView.frame.size);
This code was working earlier today, then randomly stopped, something must of changed, but
I must be doing something dumb, or maybe missing some crucial part of the
I put off asking this as it must be something daft and, given it
There must be something wrong. I don't know what? see this on jsfiddle .
This seems very basic and I must be missing something, but here goes anyways...
I must be missing something very simple, but can't find the answer to this.
I tried the solution from this thread , but I must be missing something
I've scoured Google and this site pretty extensively, and I must be missing something.

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.