public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95022] New: ICE: expected integer_cst, have call_expr
@ 2020-05-09 17:47 john at mcfarlane dot name
  2020-05-11  0:35 ` [Bug c++/95022] " mpolacek at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: john at mcfarlane dot name @ 2020-05-09 17:47 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95022
           Summary: ICE: expected integer_cst, have call_expr
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: john at mcfarlane dot name
  Target Milestone: ---

Doesn't occur with g++-9 but does happen with Ubuntu 20.04 GCC-10 and at head
w. SHA a33649e6

Ubuntu 20.04 GCC-10:
john@carbon:~/ws/gcc/build$ g++ --version
g++ (Ubuntu 10-20200411-0ubuntu1) 10.0.1 20200411 (experimental) [master
revision bb87d5cc77d:75961caccb7:f883c46b4877f637e0fa5025b4d6b5c9040ec566]
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Build from SHA a33649e6:
john@carbon:~/ws/gcc/build$ ~/gcc-a33649e6/bin/g++ --version
g++ (GCC) 11.0.0 20200509 (experimental)
Copyright © 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

The backtrace from the a33649e6 build is:
- - - - - - - - - - - - - - - >8 - - - - - - - - - - - - - - - 
john@carbon:~/ws/gcc/build$ ~/gcc-a33649e6/bin/g++
/home/john/ws/ubuntu-20.04/repro/source.cpp
/home/john/ws/ubuntu-20.04/repro/source.cpp: In instantiation of ‘struct
l<char>’:
/home/john/ws/ubuntu-20.04/repro/source.cpp:13:56:   required from ‘struct n<2,
2>’
/home/john/ws/ubuntu-20.04/repro/source.cpp:15:65:   required by substitution
of ‘template<int ar, int as, class al> decltype (n<ar, as>()) ap(al) [with int
ar = 2; int as = 2; al = G]’
/home/john/ws/ubuntu-20.04/repro/source.cpp:24:22:   required from here
/home/john/ws/ubuntu-20.04/repro/source.cpp:11:42: internal compiler error:
tree check: expected integer_cst, have call_expr in to_wide, at tree.h:5901
   11 |   auto m() -> decltype(decltype(aa<al>() >> g<h<>::c - 1>{}){});
      |                                 ~~~~~~~~~^~~~~~~~~~~~~~~~~~
0x7df747 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../gcc/gcc/tree.c:9731
0x7df929 tree_check(tree_node const*, char const*, int, char const*, tree_code)
        ../../gcc/gcc/tree.h:3550
0x7df929 wi::to_wide(tree_node const*)
        ../../gcc/gcc/tree.h:5901
0x7e1ad8 wi::to_wide(tree_node const*)
        ../../gcc/gcc/tree.c:7407
0x7e1ad8 tree_int_cst_sgn(tree_node const*)
        ../../gcc/gcc/tree.c:7399
0xa90398 cp_build_binary_op(op_location_t const&, tree_code, tree_node*,
tree_node*, int)
        ../../gcc/gcc/cp/typeck.c:5633
0x89c857 build_new_op_1
        ../../gcc/gcc/cp/call.c:6524
0x89d1cd build_new_op(op_location_t const&, tree_code, int, tree_node*,
tree_node*, tree_node*, tree_node**, int)
        ../../gcc/gcc/cp/call.c:6570
0xa83603 build_x_binary_op(op_location_t const&, tree_code, tree_node*,
tree_code, tree_node*, tree_code, tree_node**, int)
        ../../gcc/gcc/cp/typeck.c:4268
0xa19a84 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../gcc/gcc/cp/pt.c:19438
0xa1f424 tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:15913
0xa19ee8 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../gcc/gcc/cp/pt.c:20289
0xa1f424 tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:15913
0xa299aa tsubst_function_type
        ../../gcc/gcc/cp/pt.c:14899
0xa1f020 tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:15720
0xa2d84a tsubst_function_decl
        ../../gcc/gcc/cp/pt.c:13756
0xa1751f tsubst_decl
        ../../gcc/gcc/cp/pt.c:14197
0xa3a3db instantiate_class_template_1
        ../../gcc/gcc/cp/pt.c:11798
0xa3b9f2 instantiate_class_template(tree_node*)
        ../../gcc/gcc/cp/pt.c:12106
0xa82039 complete_type(tree_node*)
        ../../gcc/gcc/cp/typeck.c:137
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
- - - - - - - - - - - - - - - >8 - - - - - - - - - - - - - - - 

and the source.cpp input is:
- - - - - - - - - - - - - - - >8 - - - - - - - - - - - - - - - 
template <int a> struct b { static constexpr int c = a; };
template <typename d> auto aa() -> decltype(d());
template <int e> struct g {
  using f = __int128;
  constexpr operator f() { return e; }
};
template <class = void> struct h;
template <typename> struct k : b<8> {};
template <> struct h<> : k<char> {};
template <typename al> struct l {
  auto m() -> decltype(decltype(aa<al>() >> g<h<>::c - 1>{}){});
};
template <typename al, int, int> auto ao() -> decltype(l<al>());
template <int ar, int as> struct n { auto o() -> decltype(ao<char, ar, as>); };
template <int ar, int as = 2, class al> auto ap(al) -> decltype(n<ar, as>());
class G {
public:
  G();
  template <class al> constexpr G(al p) : ay(p) {}
  int ay;
};
template <class = int> using az = G;
auto i = az<>(g<7>{});
auto j = ap<2>(az<>{})
- - - - - - - - - - - - - - - >8 - - - - - - - - - - - - - - - 

The same code compiled with g++-9

john@carbon:~/ws/gcc/build$ g++-9 --version
g++-9 (Ubuntu 9.3.0-10ubuntu2) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Does not produce an ICE but produces a diagnostic instead:

john@carbon:~/ws/gcc/build$ g++-9 source.cpp
/home/john/ws/ubuntu-20.04/repro/source.cpp: In instantiation of ‘struct n<2,
2>’:
/home/john/ws/ubuntu-20.04/repro/source.cpp:15:65:   required by substitution
of ‘template<int ar, int as, class al> decltype (n<ar, as>()) ap(al) [with int
ar = 2; int as = 2; al = G]’
/home/john/ws/ubuntu-20.04/repro/source.cpp:24:22:   required from here
/home/john/ws/ubuntu-20.04/repro/source.cpp:14:43: error: function returning a
function
   14 | template <int ar, int as> struct n { auto o() -> decltype(ao<char, ar,
as>); };
      |                                           ^
/home/john/ws/ubuntu-20.04/repro/source.cpp:24:22: error: expected ‘,’ or ‘;’
at end of input
   24 | auto j = ap<2>(az<>{})
      |                      ^

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

* [Bug c++/95022] ICE: expected integer_cst, have call_expr
  2020-05-09 17:47 [Bug c++/95022] New: ICE: expected integer_cst, have call_expr john at mcfarlane dot name
@ 2020-05-11  0:35 ` mpolacek at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-11  0:35 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Thanks for the report.  This is actually PR94955 for which I've posted a patch:
https://gcc.gnu.org/pipermail/gcc-patches/2020-May/545263.html

*** This bug has been marked as a duplicate of bug 94955 ***

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

end of thread, other threads:[~2020-05-11  0:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-09 17:47 [Bug c++/95022] New: ICE: expected integer_cst, have call_expr john at mcfarlane dot name
2020-05-11  0:35 ` [Bug c++/95022] " mpolacek 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).