# Compiler bug or misunderstanding? -- struct pointers

**URL:** <https://forums.digi.com/t/compiler-bug-or-misunderstanding-struct-pointers/10233>\
**Category:** Rabbit\
**Created:** [January 28, 2009, 10:37am UTC](https://forums.digi.com/t/compiler-bug-or-misunderstanding-struct-pointers/10233 "2009-01-28T10:37:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![GordonS](https://avatars.discourse-cdn.com/v4/letter/g/2bfe46/32.png) [@GordonS](https://forums.digi.com/u/GordonS)\
**Post date:** [January 28, 2009, 10:37am UTC](https://forums.digi.com/t/compiler-bug-or-misunderstanding-struct-pointers/10233/1 "2009-01-28T10:37:18Z")

</div>

Hi,

DC 9.52 on RCM3700.

This looks like a compiler bug, but if I’m being dumb, just say 🙂

Data:

```auto

//============================================
// New LED data structure.
//============================================

typedef struct
{
    short	CurrentCurve[101]; // (including board factors)
    char	Curve;
    // void	(*LED_on)(void);
    // void	(*LED_off)(void);
    // void	(*LED_level)(int);
    void	(*LED_on)(); // WARNING: Dynamic C does not allow parameter declarations
    void	(*LED_off)(); // here, so it can do no type checking or auto-promotion!
    void	(*LED_level)(); // (See user manual 4.16)
} t_Led_Data;

//============================================
// New Channel data structure.
//============================================

typedef struct
{
    char	Focus;
    char	State; // (On/Off .. how to interwork with TTL?)
    char	Code;
    char	Bonded;
    char	Current_Max; // in 1/10 Amp steps
    char	RQ_level;
    char	LED_level;
    char	POD_level;
    char	PCapp_level;
    char	chan_text[3];
    char	label[10];
    char	Switches;
    char	PhysicalControl;
    short	Temperature; // in 1/10 degree steps.
    char	DigiPot[101]; // (tuneable?)
    // char	Peltier[101]; // &lt;&lt;= 2 (tuneable?)	Probably pointless.
    t_Led_Data	*pled_A;
    t_Led_Data	*pled_B;
    t_Led_Data	*pled_C;
    t_Led_Data	*pled_D;
} t_Channel_Data;

/* #memmap root .. didn't help */

t_Led_Data	Led_A;
t_Led_Data	Led_B;
t_Led_Data	Led_C;
t_Led_Data	Led_D;
t_Channel_Data	Channel_A;
t_Channel_Data	Channel_B;
t_Channel_Data	Channel_C;
t_Channel_Data	Channel_D;
t_Channel_Data	*pchan_A;
t_Channel_Data	*pchan_B;
t_Channel_Data	*pchan_C;
t_Channel_Data	*pchan_D;
t_Channel_Data	*Channel_Focus; // points to channel that has the control focus

/* #memmap xmem .. didn't help */

```

The data is now part initialised, e.g. (from Watches):

```auto

-- pchan_B struct * 0xBD33
+- *pchan_B struct
     --...
     --...
     --...
     --...
     --...
     --RQ_level char 0 (offset 5)
     --LED_level char 17 (offset 6)

```

But the following code does not see them as different:

```auto

    } else if( pchan_B-&gt;LED_level != pchan_B-&gt;RQ_level )
    {
          // Never gets here
    }

```

Single-stepping through the assembler is appears to do sensible things, reading in and calculating the address as I expect, but when it loads from the pointer-to locations, the data in the registers are both 0x0000 and, of course, the results are then equal so the test fails.

As you can see I tried putting the structs and pointers into root, but to no effect.

The calculated pointers are 0xBD38 and 0xBD39 as one would presumably expect.

Am I being dumb?

Thanks,  
Gordon.

---

<div class="post-metadata">

**Author:** ![GordonS](https://avatars.discourse-cdn.com/v4/letter/g/2bfe46/32.png) [@GordonS](https://forums.digi.com/u/GordonS)\
**Post date:** [January 28, 2009, 11:04am UTC](https://forums.digi.com/t/compiler-bug-or-misunderstanding-struct-pointers/10233/2 "2009-01-28T11:04:02Z")

</div>

Hmmm,

Actually it _does_ get there.

It looks rather as though the Watches data was not reflecting real data. The _second_ time it hits that code, after another value is written into RQ\_level, it works OK.

Strange.
