<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 1 January 2013 19:22, Johannes Pfau <span dir="ltr"><<a href="mailto:nospam@example.com" target="_blank">nospam@example.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
This is a bug which only seems to happen with gdc-4.7. At least I can't<br>
reproduce it with gcc 4.8 but I'd like to fix it in 4.7 as well if<br>
possible. (It prevents some phobos modules from being built in unittest<br>
mode).<br>
<br>
First, here's the reduced test case:<br>
----------------<br>
void main()<br>
{<br>
    topNIndex();<br>
}<br>
<br>
void topNIndex()() //<= only fails if this is a template<br>
{<br>
    bool indirectLess(int a, int b) //<= adding 'static' makes it work<br>
    {<br>
        return a > b;<br>
    }<br>
    auto a = BinaryHeap!(indirectLess)();<br>
}<br>
<br>
struct BinaryHeap(alias less )<br>
{<br>
    void percolateDown()<br>
    {<br>
        less(0, 1);<br>
    }<br>
}<br>
----------------<br>
<br>
It's somehow related to closures in templated functions. Making<br>
topNIndex a function or making indirectLess static fixes the issue.<br>
<br>
This is the compiler error:<br>
----------------<br>
bug/std/algorithm2.d:1: error: missing callgraph edge for call stmt:<br>
algorithm2.topNIndex!().topNIndex.indirectLess (0B, 0, 1);<br>
<br>
algorithm2.topNIndex!().topNIndex.BinaryHeap!(indirectLess).BinaryHeap.percolateDown/3<br>
@0x7fe2ce7a6b40 (asm:<br>
_D10algorithm214__T9topNIndexZ9topNIndexFZv82__T10BinaryHeapS63_D10algorithm214__T9topNIndexZ9topNIndexFZv12indirectLessMFiiZbZ10BinaryHeap13percolateDownMFZv)<br>
analyzed needed reachable body finalized called by: calls:<br>
_d_assert_msg/5 (1.00 per call) References: Refering this function:<br>
bug/std/algorithm2.d:1: internal compiler error: verify_cgraph_node<br>
failed<br>
----------------<br>
<br>
Any clue what to do about this?<br>
* Was it probably a gdc specific issue fixed in master but missed when<br>
  backporting?<br>
* Could be an issue fixed in the GCC backend, but I can't find a<br>
  matching bug report?<br>
* Any clue how to debug this further?<br>
</blockquote></div><br><br></div><div class="gmail_extra">Only two suggestions I can give are:<br><br>a) Make sure that indirectLess DECL_CONTEXT is topNIndex, and not main in code generation (eg: you don't want it to look logically like this)<br>
<br>void main()<br>
{<br>    bool indirectLess(int a, int b)<br>
    {<br>
        return a > b;<br>
    }<br>
    topNIndex();<br>
}<br>
<br>
void topNIndex()<br>
{<br>
    auto a = BinaryHeap!(indirectLess);<br>
}<br></div><div class="gmail_extra"><br><br></div><div class="gmail_extra">b) Make sure that indirectLess is codegen'd and pushed before topNIndex.<br></div><div class="gmail_extra"><br clear="all"><br></div><div class="gmail_extra">
Regards,<br></div><div class="gmail_extra">-- <br>Iain Buclaw<br><br>*(p < e ? p++ : p) = (c & 0x0f) + '0';
</div></div>