Bug 60198

Summary: ICE with _Cilk_spawn in expression within template function
Product: gcc Reporter: Volker Reichelt <reichelt>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED WONTFIX    
Severity: normal CC: bviyer, hvdieren, webrown.cpp
Priority: P3 Keywords: ice-on-valid-code
Version: 4.9.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: 4.9.0 Last reconfirmed: 2015-02-10 00:00:00
Bug Depends on:    
Bug Blocks: 69582    

Description Volker Reichelt 2014-02-14 15:35:20 UTC
The following valid(?) code snippet (compiled with "-fcilkplus") triggers
an ICE on trunk:

===========================================
template<typename T> int foo()
{
  int i = (_Cilk_spawn foo<T>()) + 0;
  return i;
}

template int foo<int>();
===========================================

bug.cc: In instantiation of 'int foo() [with T = int]':
bug.cc:7:23:   required from here
bug.cc:3:31: internal compiler error: in tsubst_copy, at cp/pt.c:12887
   int i = (_Cilk_spawn foo<T>()) + 0;
                               ^
0x62a933 tsubst_copy
        ../../gcc/gcc/cp/pt.c:12887
0x607956 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
        ../../gcc/gcc/cp/pt.c:15110
0x608fda tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
        ../../gcc/gcc/cp/pt.c:14188
0x6115c6 tsubst_expr
        ../../gcc/gcc/cp/pt.c:13812
0x61435d tsubst_expr
        ../../gcc/gcc/cp/pt.c:13327
0x611093 tsubst_expr
        ../../gcc/gcc/cp/pt.c:13219
0x61208c tsubst_expr
        ../../gcc/gcc/cp/pt.c:13424
0x60f2a9 instantiate_decl(tree_node*, int, bool)
        ../../gcc/gcc/cp/pt.c:19690
0x64d8c7 instantiate_pending_templates(int)
        ../../gcc/gcc/cp/pt.c:19806
0x688bed cp_write_global_declarations()
        ../../gcc/gcc/cp/decl2.c:4148
Please submit a full bug report, [etc.]
Comment 1 Volker Reichelt 2014-02-14 15:36:33 UTC
Balaji, this is your domain, would you mind having a look?
Comment 2 Sylwester Arabas 2014-02-18 10:14:45 UTC
Hi,

I've just got the same error with current Debian's gcc-snapshot (20140212) when trying to compile a code that uses the Blitz++ library, and after replacing all "#pragma ivdep" with "#pragma GCC ivdep" in that library...

    /usr/include/blitz/globeval.cc:466:12: internal compiler error: in tsubst_copy, at cp/pt.c:12887
           for (; i < uneven_start; ++i)
                ^
    Please submit a full bug report,
    with preprocessed source if appropriate.

I can provide more details if needed.

HTH,
Sylwester
Comment 3 Balaji V. Iyer 2014-02-18 14:20:09 UTC
(In reply to Sylwester Arabas from comment #2)
> Hi,
> 
> I've just got the same error with current Debian's gcc-snapshot (20140212)
> when trying to compile a code that uses the Blitz++ library, and after
> replacing all "#pragma ivdep" with "#pragma GCC ivdep" in that library...
> 
>     /usr/include/blitz/globeval.cc:466:12: internal compiler error: in
> tsubst_copy, at cp/pt.c:12887
>            for (; i < uneven_start; ++i)
>                 ^
>     Please submit a full bug report,
>     with preprocessed source if appropriate.
> 
> I can provide more details if needed.

Hi Sylwester,
    The issue with #pragma ivdep is not relevant for this bug. Can you please open another bug report for that and discuss it there?

Thanks,

Balaji V. Iyer.


> 
> HTH,
> Sylwester
Comment 4 Sylwester Arabas 2014-02-18 23:00:31 UTC
Here it is:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60267

HTH,
Sylwester
Comment 5 Andrew Pinski 2015-02-10 06:22:22 UTC
Confirmed.
Comment 6 Andrew Pinski 2015-02-10 06:37:58 UTC
*** Bug 61286 has been marked as a duplicate of this bug. ***
Comment 7 Hans Vandierendonck 2015-05-01 08:36:59 UTC
The following code snippet
===========================================
template<typename T> int foo()
{
  int i = (_Cilk_spawn foo<T>()) + 0;
  return i;
}

template int foo<int>();
===========================================

is invalid. You are not allowed to use the result of a spawned function until after a _Cilk_sync; statement.

But that is no excuse for an ICE.
Comment 8 Paolo Carlini 2017-12-04 10:53:59 UTC
Cilk Plus, deprecated for 7.x, will not be in 8.x.