Menu

#2467 sdcc/msvc - crash due to bad dereference operator usage

closed-fixed
None
other
5
2016-07-29
2016-02-03
No

Hello SDCC team,

MSVC complains about this in tree_dec_ralloc_forget():

unsigned short int i = *(old_inst.begin());

If the list is empty, the dereference is not valid, and crashes msvc in debug mode,
which is correct, as you cannot dereference an empty list.

What is the correct fix here? Return? Default value for "i" ?

Thanks,

/pedro

Discussion

  • Philipp Klaus Krause

    • assigned_to: Philipp Klaus Krause
     
  • Philipp Klaus Krause

    I can reproduce the issue of an empty set on my Debian GNU/Linux with divuint.c from the standard library when compiling for hc08 , and on atof.c when compiling for stm8.
    There is no correct fix here. I'll place a wassert(old_inst.size() == 1); before that line, once I have found and fixed why the set is empty.

    Philipp

     
  • Philipp Klaus Krause

    I was able to track down the bug. The tree-decomposition was not as nice as it should have been. This is thus a bug in the tree-decomposition nicifications stage. A patch fixing it is attached to this post.
    Unfortunately, the fix triggers hc08 bug [#2450], so bug #2450 will have to be fixed before the patch can be applied.

    Philipp

     

    Related

    Bugs: #2450


    Last edit: Maarten Brock 2016-02-03
  • Philipp Klaus Krause

    • status: open --> closed-fixed
     
  • Philipp Klaus Krause

    Fixed in revision [r9682].

    Philipp

     

    Last edit: Maarten Brock 2017-11-12

Log in to post a comment.