public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94628] New: segfault decltype
@ 2020-04-16 21:41 roland at rschulz dot eu
  2020-04-16 21:55 ` [Bug c++/94628] " mpolacek at gcc dot gnu.org
                   ` (20 more replies)
  0 siblings, 21 replies; 22+ messages in thread
From: roland at rschulz dot eu @ 2020-04-16 21:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

            Bug ID: 94628
           Summary: segfault decltype
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: roland at rschulz dot eu
  Target Milestone: ---

GCC 9.3 and trunk. Internal compiler error: Segmentation fault

#include <type_traits>
#include <utility>

template<int i>
using int_constant = std::integral_constant<int, i>;

template<int I, int...Is, class F, class...Args>
auto select(int i, F&&f, Args&&...args) -> 
    std::common_type_t<decltype(std::forward<F>(f)(int_constant<I>(), 
std::forward<decltype(args)>(args)...)),
                       decltype(std::forward<F>(f)(int_constant<Is>(),
std::forward<decltype(args)>(args)...))...>
{
    if (i == I) return std::forward<F>(f)(int_constant<I>(),
std::forward<Args>(args)...);
    else {
        if constexpr(sizeof...(Is)>0) 
            return select<Is...>(i, std::forward<F>(f),
std::forward<Args>(args)...);
    }
}

int t(int i) {
    return select<0, 1>(i, [](auto x){ return int(x);});
}


No problem if `decltype(args)` is replaced with `Args`. 

https://godbolt.org/z/kPpEK8

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] segfault decltype
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
@ 2020-04-16 21:55 ` mpolacek at gcc dot gnu.org
  2020-04-17  6:35 ` [Bug c++/94628] [8/9/10 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b marxin at gcc dot gnu.org
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-04-16 21:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |mpolacek at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-04-16

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] [8/9/10 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
  2020-04-16 21:55 ` [Bug c++/94628] " mpolacek at gcc dot gnu.org
@ 2020-04-17  6:35 ` marxin at gcc dot gnu.org
  2020-04-17  7:04 ` rguenth at gcc dot gnu.org
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-04-17  6:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
            Summary|segfault decltype           |[8/9/10 Regression] ICE in
                   |                            |invalid_nonstatic_memfn_p
                   |                            |at cp/typeck.c:1979 since
                   |                            |r9-640-g1268ecc26fc1289b
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org
      Known to fail|                            |10.0, 8.4.0, 9.3.0
      Known to work|                            |8.1.0
            Version|unknown                     |10.0

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed, started with r9-640-g1268ecc26fc1289b and it's also present on GCC-8
branch.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] [8/9/10 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
  2020-04-16 21:55 ` [Bug c++/94628] " mpolacek at gcc dot gnu.org
  2020-04-17  6:35 ` [Bug c++/94628] [8/9/10 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b marxin at gcc dot gnu.org
@ 2020-04-17  7:04 ` rguenth at gcc dot gnu.org
  2020-04-18 14:41 ` ppalka at gcc dot gnu.org
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-04-17  7:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
   Target Milestone|---                         |8.5

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] [8/9/10 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
                   ` (2 preceding siblings ...)
  2020-04-17  7:04 ` rguenth at gcc dot gnu.org
@ 2020-04-18 14:41 ` ppalka at gcc dot gnu.org
  2020-04-18 14:42 ` ppalka at gcc dot gnu.org
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-04-18 14:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Reduced rejects-valid testcase:

int f(int, int);
int f(int);

template<class...Args>
auto select(Args... args) -> decltype(f(args...))
{
  if constexpr(sizeof...(Args)>1) 
    return select<char>(7);
  else
    return 0;
}

int a = select(0, 1);



Replace 'args...' with 'decltype(args){}' to make it ICE-on-valid.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] [8/9/10 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
                   ` (3 preceding siblings ...)
  2020-04-18 14:41 ` ppalka at gcc dot gnu.org
@ 2020-04-18 14:42 ` ppalka at gcc dot gnu.org
  2020-04-18 22:00 ` xerofoify at gmail dot com
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-04-18 14:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Patrick Palka from comment #3)
> Reduced rejects-valid testcase:
> 
> int f(int, int);
> int f(int);
> 
> template<class...Args>
> auto select(Args... args) -> decltype(f(args...))
> {
>   if constexpr(sizeof...(Args)>1) 
>     return select<char>(7);
>   else
>     return 0;
> }
> 
> int a = select(0, 1);
> 
> 
> 
> Replace 'args...' with 'decltype(args){}' to make it ICE-on-valid.

Oops, that should say 'decltype(args){}...'

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] [8/9/10 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
                   ` (4 preceding siblings ...)
  2020-04-18 14:42 ` ppalka at gcc dot gnu.org
@ 2020-04-18 22:00 ` xerofoify at gmail dot com
  2020-04-18 23:36 ` mpolacek at gcc dot gnu.org
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: xerofoify at gmail dot com @ 2020-04-18 22:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

Nicholas Krause <xerofoify at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |xerofoify at gmail dot com

--- Comment #5 from Nicholas Krause <xerofoify at gmail dot com> ---
Shouldn't we also we testing for TYPE_ARGUMENT_PACK as well?  Seems to be
missing in the reported patch id and is not checked higher up the stack after
looking through the code it seems.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] [8/9/10 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
                   ` (5 preceding siblings ...)
  2020-04-18 22:00 ` xerofoify at gmail dot com
@ 2020-04-18 23:36 ` mpolacek at gcc dot gnu.org
  2020-04-19 14:42 ` ppalka at gcc dot gnu.org
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-04-18 23:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Nicholas Krause from comment #5)
> Shouldn't we also we testing for TYPE_ARGUMENT_PACK as well?  Seems to be
> missing in the reported patch id and is not checked higher up the stack
> after looking through the code it seems.

No, that doesn't fix the ICE.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] [8/9/10 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
                   ` (6 preceding siblings ...)
  2020-04-18 23:36 ` mpolacek at gcc dot gnu.org
@ 2020-04-19 14:42 ` ppalka at gcc dot gnu.org
  2020-04-20  4:26 ` xerofoify at gmail dot com
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-04-19 14:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] [8/9/10 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
                   ` (7 preceding siblings ...)
  2020-04-19 14:42 ` ppalka at gcc dot gnu.org
@ 2020-04-20  4:26 ` xerofoify at gmail dot com
  2020-04-20  7:42 ` marxin at gcc dot gnu.org
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: xerofoify at gmail dot com @ 2020-04-20  4:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

--- Comment #7 from Nicholas Krause <xerofoify at gmail dot com> ---
After adding this it seems to work for me, Patrick:
   case TYPE_ARGUMENT_PACK:
        if (value_dependent_expression_p(TREE_TYPE(*tp)))
         return *tp;
        if (TEMPLATE_TYPE_PARAMETER_PACK(*tp))
         return *tp;
    return NULL_TREE;

and gives me:
test.c: In function ‘std::common_type_t<decltype
(forward<F>(f)(std::integral_constant<int, i>(),
(forward<decltype(args)>)(args)...)), decltype
(forward<F>(f)(int_constant<Is>(), (forward<decltype(args)>)(args)...))...>
select(int, F&&, Args&& ...)’:
test.c:14:12: warning: ‘if constexpr’ only available with ‘-std=c++17’ or
‘-std=gnu++17’
   14 |         if constexpr(sizeof...(Is)>0)
      |            ^~~~~~~~~
test.c: In function ‘std::common_type_t<decltype
(forward<F>(f)(std::integral_constant<int, i>(),
(forward<decltype(select::args)>)(select::args)...)), decltype
(forward<F>(f)(int_constant<Is>(),
(forward<decltype(select::args)>)(select::args)...))...> select(int, F&&,
Args&& ...) [with int I = 1; int ...Is = {}; F = t(int)::<lambda(auto:1)>; Args
= {}]’:
test.c:17:1: warning: control reaches end of non-void function [-Wreturn-type]
   17 | }
      | ^

with no segfault. I'm not sure if this is the correct part to add this test for
TYPE_ARGUMENT_PACK or if we would prefer it to be lower in the stack.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] [8/9/10 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
                   ` (8 preceding siblings ...)
  2020-04-20  4:26 ` xerofoify at gmail dot com
@ 2020-04-20  7:42 ` marxin at gcc dot gnu.org
  2020-04-20 18:55 ` xerofoify at gmail dot com
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-04-20  7:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

--- Comment #8 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Nicholas Krause from comment #7)
> After adding this it seems to work for me, Patrick:
>    case TYPE_ARGUMENT_PACK:
>         if (value_dependent_expression_p(TREE_TYPE(*tp)))
>          return *tp;
>         if (TEMPLATE_TYPE_PARAMETER_PACK(*tp))
>          return *tp;
>     return NULL_TREE;
> 
> and gives me:
> test.c: In function ‘std::common_type_t<decltype
> (forward<F>(f)(std::integral_constant<int, i>(),
> (forward<decltype(args)>)(args)...)), decltype
> (forward<F>(f)(int_constant<Is>(), (forward<decltype(args)>)(args)...))...>
> select(int, F&&, Args&& ...)’:
> test.c:14:12: warning: ‘if constexpr’ only available with ‘-std=c++17’ or
> ‘-std=gnu++17’
>    14 |         if constexpr(sizeof...(Is)>0)
>       |            ^~~~~~~~~
> test.c: In function ‘std::common_type_t<decltype
> (forward<F>(f)(std::integral_constant<int, i>(),
> (forward<decltype(select::args)>)(select::args)...)), decltype
> (forward<F>(f)(int_constant<Is>(),
> (forward<decltype(select::args)>)(select::args)...))...> select(int, F&&,
> Args&& ...) [with int I = 1; int ...Is = {}; F = t(int)::<lambda(auto:1)>;
> Args = {}]’:
> test.c:17:1: warning: control reaches end of non-void function
> [-Wreturn-type]
>    17 | }
>       | ^
> 
> with no segfault. I'm not sure if this is the correct part to add this test
> for TYPE_ARGUMENT_PACK or if we would prefer it to be lower in the stack.

The suggested change is wrong:

/home/marxin/Programming/gcc2/objdir/./gcc/xgcc -shared-libgcc
-B/home/marxin/Programming/gcc2/objdir/./gcc -nostdinc++
-L/home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/libstdc++-v3/src
-L/home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs
-L/home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs
-B/usr/local/x86_64-pc-linux-gnu/bin/ -B/usr/local/x86_64-pc-linux-gnu/lib/
-isystem /usr/local/x86_64-pc-linux-gnu/include -isystem
/usr/local/x86_64-pc-linux-gnu/sys-include    -x c++-header -nostdinc++ -g -O2
-D_GNU_SOURCE 
-I/home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu
-I/home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/libstdc++-v3/include
-I/home/marxin/Programming/gcc2/libstdc++-v3/libsupc++  -O2 -g -std=gnu++0x
/home/marxin/Programming/gcc2/libstdc++-v3/include/precompiled/stdc++.h \
-o x86_64-pc-linux-gnu/bits/stdc++.h.gch/O2ggnu++0x.gch
In file included from
/home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/libstdc++-v3/include/cmath:42,
                 from
/home/marxin/Programming/gcc2/libstdc++-v3/include/precompiled/stdc++.h:41:
/home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/cpp_type_traits.h:89:63:
internal compiler error: tree check: expected template_type_parm or
template_template_parm or bound_template_template_parm, have tree_list in
instantiation_dependent_r, at cp/pt.c:26926
   89 |       enum { __value = bool(_Sp::__value) || bool(_Tp::__value) };
      |                                                               ^
0x8404c2 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../gcc/tree.c:9727
0x69234b tree_check3(tree_node*, char const*, int, char const*, tree_code,
tree_code, tree_code)
        ../../gcc/tree.h:3327
0x69234b instantiation_dependent_r
        ../../gcc/cp/pt.c:26926
0x13749b3 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ../../gcc/tree.c:11996
0xb10a88 cp_walk_subtrees(tree_node**, int*, tree_node* (*)(tree_node**, int*,
void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)
        ../../gcc/cp/tree.c:5061
0x1374a47 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ../../gcc/tree.c:12019
0x1377c85 walk_tree_without_duplicates_1(tree_node**, tree_node*
(*)(tree_node**, int*, void*), void*, tree_node* (*)(tree_node**, int*,
tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false,
default_hash_traits<tree_node*> >*))
        ../../gcc/tree.c:12352
0xa97c87 instantiation_dependent_uneval_expression_p(tree_node*)
        ../../gcc/cp/pt.c:27033
0xa9e278 instantiation_dependent_expression_p(tree_node*)
        ../../gcc/cp/pt.c:27043
0x973ba7 is_nondependent_constant_expression(tree_node*)
        ../../gcc/cp/constexpr.c:8300
0x973fca fold_non_dependent_expr_template
        ../../gcc/cp/constexpr.c:6970
0xa98147 build_non_dependent_expr(tree_node*)
        ../../gcc/cp/pt.c:27531
0xb271ef build_x_binary_op(op_location_t const&, tree_code, tree_node*,
tree_code, tree_node*, tree_code, tree_node**, int)
        ../../gcc/cp/typeck.c:4245
0xa54e71 cp_parser_binary_expression
        ../../gcc/cp/parser.c:9719
0xa5671e cp_parser_assignment_expression
        ../../gcc/cp/parser.c:9859
0xa556cd cp_parser_constant_expression
        ../../gcc/cp/parser.c:10153
0xa62028 cp_parser_enumerator_definition
        ../../gcc/cp/parser.c:19479
0xa62028 cp_parser_enumerator_list
        ../../gcc/cp/parser.c:19419
0xa62028 cp_parser_enum_specifier
        ../../gcc/cp/parser.c:19350
0xa62028 cp_parser_type_specifier
        ../../gcc/cp/parser.c:17680

Can you please next time send patch suggestion that at least survive GCC build?

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] [8/9/10 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
                   ` (9 preceding siblings ...)
  2020-04-20  7:42 ` marxin at gcc dot gnu.org
@ 2020-04-20 18:55 ` xerofoify at gmail dot com
  2020-04-20 18:57 ` xerofoify at gmail dot com
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: xerofoify at gmail dot com @ 2020-04-20 18:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

--- Comment #9 from Nicholas Krause <xerofoify at gmail dot com> ---
Created attachment 48318
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48318&action=edit
Possible Fix

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] [8/9/10 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
                   ` (10 preceding siblings ...)
  2020-04-20 18:55 ` xerofoify at gmail dot com
@ 2020-04-20 18:57 ` xerofoify at gmail dot com
  2020-04-20 19:10 ` mpolacek at gcc dot gnu.org
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: xerofoify at gmail dot com @ 2020-04-20 18:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

--- Comment #10 from Nicholas Krause <xerofoify at gmail dot com> ---
(In reply to Martin Liška from comment #8)
> (In reply to Nicholas Krause from comment #7)
> > After adding this it seems to work for me, Patrick:
> >    case TYPE_ARGUMENT_PACK:
> >         if (value_dependent_expression_p(TREE_TYPE(*tp)))
> >          return *tp;
> >         if (TEMPLATE_TYPE_PARAMETER_PACK(*tp))
> >          return *tp;
> >     return NULL_TREE;
> > 
> > and gives me:
> > test.c: In function ‘std::common_type_t<decltype
> > (forward<F>(f)(std::integral_constant<int, i>(),
> > (forward<decltype(args)>)(args)...)), decltype
> > (forward<F>(f)(int_constant<Is>(), (forward<decltype(args)>)(args)...))...>
> > select(int, F&&, Args&& ...)’:
> > test.c:14:12: warning: ‘if constexpr’ only available with ‘-std=c++17’ or
> > ‘-std=gnu++17’
> >    14 |         if constexpr(sizeof...(Is)>0)
> >       |            ^~~~~~~~~
> > test.c: In function ‘std::common_type_t<decltype
> > (forward<F>(f)(std::integral_constant<int, i>(),
> > (forward<decltype(select::args)>)(select::args)...)), decltype
> > (forward<F>(f)(int_constant<Is>(),
> > (forward<decltype(select::args)>)(select::args)...))...> select(int, F&&,
> > Args&& ...) [with int I = 1; int ...Is = {}; F = t(int)::<lambda(auto:1)>;
> > Args = {}]’:
> > test.c:17:1: warning: control reaches end of non-void function
> > [-Wreturn-type]
> >    17 | }
> >       | ^
> > 
> > with no segfault. I'm not sure if this is the correct part to add this test
> > for TYPE_ARGUMENT_PACK or if we would prefer it to be lower in the stack.
> 
> The suggested change is wrong:
> 
> /home/marxin/Programming/gcc2/objdir/./gcc/xgcc -shared-libgcc
> -B/home/marxin/Programming/gcc2/objdir/./gcc -nostdinc++
> -L/home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/libstdc++-v3/src
> -L/home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/libstdc++-v3/src/.
> libs
> -L/home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/libstdc++-v3/
> libsupc++/.libs -B/usr/local/x86_64-pc-linux-gnu/bin/
> -B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem
> /usr/local/x86_64-pc-linux-gnu/include -isystem
> /usr/local/x86_64-pc-linux-gnu/sys-include    -x c++-header -nostdinc++ -g
> -O2 -D_GNU_SOURCE 
> -I/home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/libstdc++-v3/
> include/x86_64-pc-linux-gnu
> -I/home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/libstdc++-v3/
> include -I/home/marxin/Programming/gcc2/libstdc++-v3/libsupc++  -O2 -g
> -std=gnu++0x
> /home/marxin/Programming/gcc2/libstdc++-v3/include/precompiled/stdc++.h \
> -o x86_64-pc-linux-gnu/bits/stdc++.h.gch/O2ggnu++0x.gch
> In file included from
> /home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/libstdc++-v3/
> include/cmath:42,
>                  from
> /home/marxin/Programming/gcc2/libstdc++-v3/include/precompiled/stdc++.h:41:
> /home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/libstdc++-v3/
> include/bits/cpp_type_traits.h:89:63: internal compiler error: tree check:
> expected template_type_parm or template_template_parm or
> bound_template_template_parm, have tree_list in instantiation_dependent_r,
> at cp/pt.c:26926
>    89 |       enum { __value = bool(_Sp::__value) || bool(_Tp::__value) };
>       |                                                               ^
> 0x8404c2 tree_check_failed(tree_node const*, char const*, int, char const*,
> ...)
> 	../../gcc/tree.c:9727
> 0x69234b tree_check3(tree_node*, char const*, int, char const*, tree_code,
> tree_code, tree_code)
> 	../../gcc/tree.h:3327
> 0x69234b instantiation_dependent_r
> 	../../gcc/cp/pt.c:26926
> 0x13749b3 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
> void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
> tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
> void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
> 	../../gcc/tree.c:11996
> 0xb10a88 cp_walk_subtrees(tree_node**, int*, tree_node* (*)(tree_node**,
> int*, void*), void*, hash_set<tree_node*, false,
> default_hash_traits<tree_node*> >*)
> 	../../gcc/cp/tree.c:5061
> 0x1374a47 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
> void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
> tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
> void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
> 	../../gcc/tree.c:12019
> 0x1377c85 walk_tree_without_duplicates_1(tree_node**, tree_node*
> (*)(tree_node**, int*, void*), void*, tree_node* (*)(tree_node**, int*,
> tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false,
> default_hash_traits<tree_node*> >*))
> 	../../gcc/tree.c:12352
> 0xa97c87 instantiation_dependent_uneval_expression_p(tree_node*)
> 	../../gcc/cp/pt.c:27033
> 0xa9e278 instantiation_dependent_expression_p(tree_node*)
> 	../../gcc/cp/pt.c:27043
> 0x973ba7 is_nondependent_constant_expression(tree_node*)
> 	../../gcc/cp/constexpr.c:8300
> 0x973fca fold_non_dependent_expr_template
> 	../../gcc/cp/constexpr.c:6970
> 0xa98147 build_non_dependent_expr(tree_node*)
> 	../../gcc/cp/pt.c:27531
> 0xb271ef build_x_binary_op(op_location_t const&, tree_code, tree_node*,
> tree_code, tree_node*, tree_code, tree_node**, int)
> 	../../gcc/cp/typeck.c:4245
> 0xa54e71 cp_parser_binary_expression
> 	../../gcc/cp/parser.c:9719
> 0xa5671e cp_parser_assignment_expression
> 	../../gcc/cp/parser.c:9859
> 0xa556cd cp_parser_constant_expression
> 	../../gcc/cp/parser.c:10153
> 0xa62028 cp_parser_enumerator_definition
> 	../../gcc/cp/parser.c:19479
> 0xa62028 cp_parser_enumerator_list
> 	../../gcc/cp/parser.c:19419
> 0xa62028 cp_parser_enum_specifier
> 	../../gcc/cp/parser.c:19350
> 0xa62028 cp_parser_type_specifier
> 	../../gcc/cp/parser.c:17680
> 
> Can you please next time send patch suggestion that at least survive GCC
> build?

I just tested this with config:
../gcc/configure --enable-lanuages=c,c++ --enable-threads -disable-multilibs
--enable-checking=yes --prefix="$HOME/obdjir"

I've attached the building patch above as build on a GNU Cauldron power
machine. No idea why it's not building for you but if you need me your config I
will look into why if the patch still does not build for.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] [8/9/10 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
                   ` (11 preceding siblings ...)
  2020-04-20 18:57 ` xerofoify at gmail dot com
@ 2020-04-20 19:10 ` mpolacek at gcc dot gnu.org
  2020-04-20 19:26 ` marxin at gcc dot gnu.org
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-04-20 19:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

--- Comment #11 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Nicholas Krause from comment #9)
> Created attachment 48318 [details]
> Possible Fix

No, it's not a fix, it just replaces an ICE with another ICE, as Martin already
pointed out:

94628-3.C:5:40: internal compiler error: tree check: expected
template_type_parm or template_template_parm or bound_template_template_parm,
have 
nontype_argument_pack in instantiation_dependent_r, at cp/pt.c:26950

and doesn't fix the rejects-valid testcase, either.

How many times do you have to be told to test your patches?  Besides, Patrick
is already working on this PR.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] [8/9/10 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
                   ` (12 preceding siblings ...)
  2020-04-20 19:10 ` mpolacek at gcc dot gnu.org
@ 2020-04-20 19:26 ` marxin at gcc dot gnu.org
  2020-04-20 22:56 ` cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-04-20 19:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

--- Comment #12 from Martin Liška <marxin at gcc dot gnu.org> ---
> How many times do you have to be told to test your patches?  Besides,
> Patrick is already working on this PR.

As Marek said, it's really unpleasant to send untested patches and so come up
with noise in bug reports.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] [8/9/10 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
                   ` (13 preceding siblings ...)
  2020-04-20 19:26 ` marxin at gcc dot gnu.org
@ 2020-04-20 22:56 ` cvs-commit at gcc dot gnu.org
  2020-04-20 22:57 ` [Bug c++/94628] [8/9 " ppalka at gcc dot gnu.org
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-20 22:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

--- Comment #13 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

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

commit r10-7835-ga3a4f6be0c7ac1536c4d1def14217840b04dd488
Author: Patrick Palka <ppalka@redhat.com>
Date:   Mon Apr 20 18:34:00 2020 -0400

    c++: Recursive unification with packs and explicit targs [PR94628]

    This PR seems to be similar to PR c++/43382, except that the recursive call
to
    the variadic function with trailing return type in this testcase is
additionally
    given some explicit template arguments.

    In the first testcase below, when resolving the recursive call to 'select',
    fn_type_unification first substitutes in the call's explicit template
arguments
    before doing unification, and so during this substitution the template
argument
    pack for Args is incomplete.

    Since the pack is incomplete, the substitution of 'args...' in the trailing
    return type decltype(f(args...)) is handled by the unsubstituted_packs case
of
    tsubst_pack_expansion.  But the handling of this case happens _before_ we
reset
    local_specializations, and so the substitution ends up reusing the old
binding
    for 'args' from local_specializations rather than building a new one.

    This patch fixes this issue by setting up local_specializations sooner in
    tsubst_pack_expansion, before the handling of the unsubstituted_packs case.
    It also adds a new policy to local_specialization_stack so that we could
use the
    class here to conditionally replace local_specializations.

    gcc/cp/ChangeLog:

            PR c++/94628
            * cp-tree.h (lss_policy::lss_nop): New enumerator.
            * pt.c (local_specialization_stack::local_specialization_stack):
Handle
            an lss_nop policy.
            (local_specialization_stack::~local_specialization_stack):
Likewise.
            (tsubst_pack_expansion): Use a local_specialization_stack instead
of
            manually saving and restoring local_specializations.  Conditionally
            replace local_specializations sooner, before the handling of the
            unsubstituted_packs case.

    gcc/testsuite/ChangeLog:

            PR c++/94628
            * g++.dg/cpp0x/variadic179.C: New test.
            * g++.dg/cpp0x/variadic180.C: New test.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] [8/9 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
                   ` (14 preceding siblings ...)
  2020-04-20 22:56 ` cvs-commit at gcc dot gnu.org
@ 2020-04-20 22:57 ` ppalka at gcc dot gnu.org
  2021-04-02 14:28 ` ppalka at gcc dot gnu.org
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-04-20 22:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
            Summary|[8/9/10 Regression] ICE in  |[8/9 Regression] ICE in
                   |invalid_nonstatic_memfn_p   |invalid_nonstatic_memfn_p
                   |at cp/typeck.c:1979 since   |at cp/typeck.c:1979 since
                   |r9-640-g1268ecc26fc1289b    |r9-640-g1268ecc26fc1289b

--- Comment #14 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 10 so far.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] [8/9 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
                   ` (15 preceding siblings ...)
  2020-04-20 22:57 ` [Bug c++/94628] [8/9 " ppalka at gcc dot gnu.org
@ 2021-04-02 14:28 ` ppalka at gcc dot gnu.org
  2021-05-04 12:32 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-04-02 14:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gufideg at gmail dot com

--- Comment #15 from Patrick Palka <ppalka at gcc dot gnu.org> ---
*** Bug 86859 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] [8/9 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
                   ` (16 preceding siblings ...)
  2021-04-02 14:28 ` ppalka at gcc dot gnu.org
@ 2021-05-04 12:32 ` rguenth at gcc dot gnu.org
  2021-05-14  9:53 ` [Bug c++/94628] [9 " jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-05-04 12:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] [9 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
                   ` (17 preceding siblings ...)
  2021-05-04 12:32 ` rguenth at gcc dot gnu.org
@ 2021-05-14  9:53 ` jakub at gcc dot gnu.org
  2021-06-01  8:17 ` rguenth at gcc dot gnu.org
  2022-05-27  8:51 ` rguenth at gcc dot gnu.org
  20 siblings, 0 replies; 22+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-14  9:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|8.5                         |9.4

--- Comment #16 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 8 branch is being closed.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] [9 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
                   ` (18 preceding siblings ...)
  2021-05-14  9:53 ` [Bug c++/94628] [9 " jakub at gcc dot gnu.org
@ 2021-06-01  8:17 ` rguenth at gcc dot gnu.org
  2022-05-27  8:51 ` rguenth at gcc dot gnu.org
  20 siblings, 0 replies; 22+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-01  8:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.4                         |9.5

--- Comment #17 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9.4 is being released, retargeting bugs to GCC 9.5.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/94628] [9 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b
  2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
                   ` (19 preceding siblings ...)
  2021-06-01  8:17 ` rguenth at gcc dot gnu.org
@ 2022-05-27  8:51 ` rguenth at gcc dot gnu.org
  20 siblings, 0 replies; 22+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27  8:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94628

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED
   Target Milestone|9.5                         |10.0

--- Comment #18 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed in GCC 10.

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2022-05-27  8:51 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
2020-04-16 21:55 ` [Bug c++/94628] " mpolacek at gcc dot gnu.org
2020-04-17  6:35 ` [Bug c++/94628] [8/9/10 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b marxin at gcc dot gnu.org
2020-04-17  7:04 ` rguenth at gcc dot gnu.org
2020-04-18 14:41 ` ppalka at gcc dot gnu.org
2020-04-18 14:42 ` ppalka at gcc dot gnu.org
2020-04-18 22:00 ` xerofoify at gmail dot com
2020-04-18 23:36 ` mpolacek at gcc dot gnu.org
2020-04-19 14:42 ` ppalka at gcc dot gnu.org
2020-04-20  4:26 ` xerofoify at gmail dot com
2020-04-20  7:42 ` marxin at gcc dot gnu.org
2020-04-20 18:55 ` xerofoify at gmail dot com
2020-04-20 18:57 ` xerofoify at gmail dot com
2020-04-20 19:10 ` mpolacek at gcc dot gnu.org
2020-04-20 19:26 ` marxin at gcc dot gnu.org
2020-04-20 22:56 ` cvs-commit at gcc dot gnu.org
2020-04-20 22:57 ` [Bug c++/94628] [8/9 " ppalka at gcc dot gnu.org
2021-04-02 14:28 ` ppalka at gcc dot gnu.org
2021-05-04 12:32 ` rguenth at gcc dot gnu.org
2021-05-14  9:53 ` [Bug c++/94628] [9 " jakub at gcc dot gnu.org
2021-06-01  8:17 ` rguenth at gcc dot gnu.org
2022-05-27  8:51 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).