Bug 96254 - d: ICE using non-local variable: internal compiler error: Segmentation fault
Summary: d: ICE using non-local variable: internal compiler error: Segmentation fault
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: d (show other bugs)
Version: 10.1.0
: P3 normal
Target Milestone: ---
Assignee: Iain Buclaw
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-20 22:40 UTC by Iain Buclaw
Modified: 2020-08-20 23:13 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Iain Buclaw 2020-07-20 22:40:24 UTC
---
struct map(alias fun)
{
    @property run()
    {
    }
}

struct Task(Args)
{
    Args _args;
}

template reduce(functions...)
{
    auto reduce(Args)(Args args)
    {
        alias RTask = Task!(typeof(args));
        auto task = RTask();
    }
}

void main()
{
    immutable delta = 1;
    reduce!"a + b"(map!({ immutable x = delta; })());
}
Comment 1 GCC Commits 2020-08-03 10:00:18 UTC
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:2b1c2a4bd9fb555dccde5d67d6da64547064e0e6

commit r11-2497-g2b1c2a4bd9fb555dccde5d67d6da64547064e0e6
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Tue Jul 21 19:59:00 2020 +0200

    d: Fix ICE using non-local variable: internal compiler error: Segmentation fault
    
    Moves no frame access error to own function, adding use of it for both
    when get_framedecl() cannot find a path to the outer function frame, and
    guarding get_decl_tree() from recursively calling itself.
    
    gcc/d/ChangeLog:
    
            PR d/96254
            * d-codegen.cc (error_no_frame_access): New.
            (get_frame_for_symbol): Use fdparent name in error message.
            (get_framedecl): Replace call to assert with error.
            * d-tree.h (error_no_frame_access): Declare.
            * decl.cc (get_decl_tree): Detect recursion and error.
    
    gcc/testsuite/ChangeLog:
    
            PR d/96254
            * gdc.dg/pr96254a.d: New test.
            * gdc.dg/pr96254b.d: New test.
Comment 2 GCC Commits 2020-08-20 23:10:33 UTC
The releases/gcc-10 branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:a5d07caca15958980ae9cc4570a784f8b1a43403

commit r10-8647-ga5d07caca15958980ae9cc4570a784f8b1a43403
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Tue Jul 21 19:59:00 2020 +0200

    d: Fix ICE using non-local variable: internal compiler error: Segmentation fault
    
    Moves no frame access error to own function, adding use of it for both
    when get_framedecl() cannot find a path to the outer function frame, and
    guarding get_decl_tree() from recursively calling itself.
    
    gcc/d/ChangeLog:
    
            PR d/96254
            * d-codegen.cc (error_no_frame_access): New.
            (get_frame_for_symbol): Use fdparent name in error message.
            (get_framedecl): Replace call to assert with error.
            * d-tree.h (error_no_frame_access): Declare.
            * decl.cc (get_decl_tree): Detect recursion and error.
    
    gcc/testsuite/ChangeLog:
    
            PR d/96254
            * gdc.dg/pr96254a.d: New test.
            * gdc.dg/pr96254b.d: New test.
    
    (cherry picked from commit 2b1c2a4bd9fb555dccde5d67d6da64547064e0e6)
Comment 3 Iain Buclaw 2020-08-20 23:13:41 UTC
Done.