Thread: MSVC debugger showing inconsistencies with dynamic arrays? Or is it bad code?

  1. #1
    Registered User Chris87's Avatar
    Join Date
    Dec 2007
    Posts
    139

    MSVC debugger showing inconsistencies with dynamic arrays? Or is it bad code?

    I've been trying to write a new importer for Assimp (Home). It seems ready for debugging, so I wrote a unit test for it. It fails with an access violation exception, so I started the debugger and breakpointed a few areas of interest.

    I'm trying to use a for-loop to read in a number of pairs of unsigned 4 byte integers (type IDs and offsets) with the total count for each being the variable `mh->sectionCount`.

    My problem is that when I execute this part of the code in the debugger, `mh->sectionCount` has a value of 7, but both `offsets` and `types` arrays are showing only one value entry each, even though the memory region for `types` (highlighted in screenshot) reflects 28 total bytes read in. I forgot to show this, but the variable `b` in the for-loop does go up to 6 as expected.

    TL;DR: I think the MSVC debugger display of locals in regards to dynamically allocated arrays is utterly bugged, but I'd like to make sure it's that and not just a mistake in my code. I cannot debug Assimp with MinGW because its linker has issues.

    MSVC debugger showing inconsistencies with dynamic arrays? Or is it bad code?-untitled-jpg
    Last edited by Chris87; 05-10-2018 at 07:42 PM.

  2. #2
    Registered User
    Join Date
    Dec 2017
    Posts
    1,628
    Maybe I'm misunderstanding you, but are you saying that you expect the lower display of Locals to show multiple values for types and offsets? They aren't really arrays, though. They are pointers that you allocated a chunk of memory to. The debugger doesn't know what use you've put the memory to.
    A little inaccuracy saves tons of explanation. - H.H. Munro

  3. #3
    Registered User Chris87's Avatar
    Join Date
    Dec 2007
    Posts
    139
    Ooooh, okay. So since they're pointers, it'll only show the first value being pointed to?

  4. #4
    Registered User
    Join Date
    Dec 2017
    Posts
    1,628
    I believe what it's showing is not the first value, but the address that's been assigned to the pointer. That's it.
    A little inaccuracy saves tons of explanation. - H.H. Munro

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New to dynamic arrays... help with my source code?
    By chubigans in forum C Programming
    Replies: 2
    Last Post: 08-29-2009, 10:41 AM
  2. MSVC: run w/o debugger vs run w/ debuger
    By skorman00 in forum C++ Programming
    Replies: 2
    Last Post: 01-24-2006, 09:49 PM
  3. Problem with MSVC debugger - can't get it to break?
    By BrianK in forum Windows Programming
    Replies: 3
    Last Post: 04-07-2004, 05:22 PM
  4. Showing Line Numbers in MSVC++
    By drdroid in forum Windows Programming
    Replies: 1
    Last Post: 01-09-2003, 03:23 PM
  5. MSVC++ Debugger (it kills me)
    By lightatdawn in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 06-29-2002, 07:37 PM

Tags for this Thread