Visual Studio .NET 2003/2005 VC debugger does not handle opaque type inspection correctly, a regression from VC 6

I believe I have found a bug in the VS 2003/2005 debugger.

When you compile the below C code and step into the create_two or function_two routines, the debugger gets the opaque type incorrect. Visual C 6 did not suffer from this problem. It appears that the debugger IDE binds the first struct definition to the opaque type across all files, but this is incorrect. Struct definitions are scoped on a per file basis.

NOTE: The source can be downloaded from:
http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx feedbackid=88dd932e-edfc-4840-8b93-95e42da8a774

I'm curious if anyone else has seen this problem and knows about a workaround.

Regars

John Kamp

DebugIssues.c
#include "DebugProblems.h"

int main(int argc, char* argv[])
{
  my_type *type_one, *type_two ;

  if (create_one(&type_one))
    function_one(type_one) ;

  if (create_two(&type_two))
    function_two(type_two) ;

  return 0;
}

DebugProblemsOne.c
#include "malloc.h"
#include "DebugProblems.h"

static char *fn = "Michael" ;
static char *ln = "Jackson" ;

struct my_type {
  char *first_name ;
  char *second_name ;
} ;

int create_one(my_type **type)
{
  my_type *new_type ;
  if (type == NULL)
    return 0 ;
  *type = NULL ;
  new_type = malloc(sizeof(my_type)) ;
  if (new_type == NULL)
    return 0 ;
  new_type->first_name = fn ;
  new_type->second_name = ln ;
  *type = new_type ;
  return 1 ;
}

void function_one(my_type *type)
{
  if (type == NULL)
    return ;
}

DebugProbelms.h
#ifndef __DEBUGPROBLEMS_H__
#define __DEBUGPROBLEMS_H__

#ifdef __cplusplus
extern "C" {
#endif

#pragma once

#define WIN32_LEAN_AND_MEAN

#include <stdio.h>
#include <tchar.h>

typedef struct my_type my_type ;

extern int create_two(my_type **type) ;
extern void function_two(my_type *type) ;

extern int create_one(my_type **type) ;
extern void function_one(my_type *type) ;

#ifdef __cplusplus
}
#endif

#endif /*!__DEBUGPROBLEMS_H__*/

DebugProblems2.c
#include "malloc.h"
#include "DebugProblems.h"

struct my_type {
  char ch ;
  unsigned int count ;
} ;

int create_two(my_type **type)
{
  my_type *new_type ;
  if (type == NULL)
    return 0 ;
  *type = NULL ;
  new_type = malloc(sizeof(my_type)) ;
  if (new_type == NULL)
    return 0 ;
  new_type->ch = 'a' ;
  new_type->count = 100 ;
  *type = new_type ;
  return 1 ;
}

void function_two(my_type *type)
{
  if (type == NULL)
    return ;
}




Answer this question

Visual Studio .NET 2003/2005 VC debugger does not handle opaque type inspection correctly, a regression from VC 6