#365 Value reused from registers after change


I ran into a nasty bug where a value read from a pointer to
a struct is held in registers and used again (rather than
derefereing the pointer again) after the pointer is
passed to
a function that changes the value.

Here's some sample code that reproduces the problem:


The specific code is:

if (list->next_random == 0)

// BUG: value of "list->next_random" previously
stored in registers is
// passed to "addr6", even though the pointer
"list" was passed to
// the "simm_id_from_pointer" function can write to
that struct and
// change this value.
return ((playlist_list_t

SDCC reads the value while evaluating the if condution,
and then uses those registers when calling addr6, even
though the code executed when the value is zero will
change it.

I tested this with a fresh checkout from CVS today
(July 27, 2002)



  • Johan Knol

    Johan Knol - 2003-01-07

    Logged In: YES

    This is a nice but tricky one. list is removed from the cseSet
    but list->next_random has already an iTemp (@-ed from list +
    structureOffset) but is not removed.

    Wonder why this doesn't happen in model-small.

  • Johan Knol

    Johan Knol - 2003-01-07
    • priority: 5 --> 7
  • Erik Petrich

    Erik Petrich - 2003-11-15
    • milestone: --> fixed
    • assigned_to: nobody --> epetrich
    • status: open --> closed-fixed
  • Erik Petrich

    Erik Petrich - 2003-11-15

    Logged In: YES

    Fixed in src/SDCCdflow.c 1.12


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks