[Bug c++/90998] [9/10 Regression] ICE (segfalut) in gcc/cp/call.c compare_ics() with -std=c++17

2019-10-29 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90998

--- Comment #4 from Marek Polacek  ---
Author: mpolacek
Date: Tue Oct 29 21:06:21 2019
New Revision: 277593

URL: https://gcc.gnu.org/viewcvs?rev=277593=gcc=rev
Log:
PR c++/90998 - ICE with copy elision in init by ctor and -Wconversion.

After r269667 which introduced joust_maybe_elide_copy, in C++17 we can elide
a constructor if it uses a conversion function that returns a prvalue, and
use the conversion function in its stead.

This eliding means that if we have a candidate that previously didn't have
->second_conv, it can have it after the elision.  This confused the
-Wconversion warning because it was assuming that if cand1->second_conv is
non-null, so is cand2->second_conv.  Here cand1->second_conv was non-null
but cand2->second_conv remained null, so it crashed in compare_ics.

I checked with clang that both compilers call A::operator B() in C++17 and
B::B(A const &) otherwise.

* call.c (joust): Don't attempt to warn if ->second_conv is null.

* g++.dg/cpp0x/overload-conv-4.C: New test.


Added:
trunk/gcc/testsuite/g++.dg/cpp0x/overload-conv-4.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/call.c
trunk/gcc/testsuite/ChangeLog

[Bug c++/90998] [9/10 Regression] ICE (segfalut) in gcc/cp/call.c compare_ics() with -std=c++17

2019-10-25 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90998

Marek Polacek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||mpolacek at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org

[Bug c++/90998] [9/10 Regression] ICE (segfalut) in gcc/cp/call.c compare_ics() with -std=c++17

2019-10-11 Thread dan at stahlke dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90998

Dan Stahlke  changed:

   What|Removed |Added

 CC||dan at stahlke dot org

--- Comment #3 from Dan Stahlke  ---
Me too, with gcc 9.2.0.

g++ -std=c++17 -Wconversion gcc-Wconversion-crash.cpp

--

struct B;

struct A {
operator B();
};

struct B {
B(A const );
B(B const );
};

B f(A x) {
return B(x);
}

--

gcc-Wconversion-crash.cpp: In function ‘B f(A)’:
gcc-Wconversion-crash.cpp:15:15: internal compiler error: Segmentation fault
   15 | return B(x);
  |   ^
0xb8d10f crash_signal
../.././gcc/toplev.c:326
0x5ff192 compare_ics
../.././gcc/cp/call.c:10124
0x603090 joust
../.././gcc/cp/call.c:10737
0x603a2c tourney
../.././gcc/cp/call.c:11096
0x60b5f6 build_new_method_call_1
../.././gcc/cp/call.c:9805
0x60b5f6 build_new_method_call(tree_node*, tree_node*, vec**, tree_node*, int, tree_node**, int)
../.././gcc/cp/call.c:9973
0x600773 build_special_member_call(tree_node*, tree_node*, vec**, tree_node*, int, int)
../.././gcc/cp/call.c:9397
0x60ca93 perform_direct_initialization_if_possible(tree_node*, tree_node*,
bool, int)
../.././gcc/cp/call.c:11314
0x746ab9 build_static_cast_1
../.././gcc/cp/typeck.c:7211
0x749807 cp_build_c_cast(tree_node*, tree_node*, int)
../.././gcc/cp/typeck.c:8007
0x749807 cp_build_c_cast(tree_node*, tree_node*, int)
../.././gcc/cp/typeck.c:7924
0x751c2a build_functional_cast(tree_node*, tree_node*, int)
../.././gcc/cp/typeck2.c:2284
0x6b3b16 cp_parser_functional_cast
../.././gcc/cp/parser.c:28385
0x6c4864 cp_parser_postfix_expression
../.././gcc/cp/parser.c:7101
0x6d1409 cp_parser_unary_expression
../.././gcc/cp/parser.c:8472
0x6af31f cp_parser_cast_expression
../.././gcc/cp/parser.c:9357
0x6afb0a cp_parser_binary_expression
../.././gcc/cp/parser.c:9460
0x6b08a7 cp_parser_assignment_expression
../.././gcc/cp/parser.c:9758
0x6b0bca cp_parser_expression
../.././gcc/cp/parser.c:9925
0x6bef8a cp_parser_jump_statement
../.././gcc/cp/parser.c:12910
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

--

g++ -v

Reading specs from
/xxx/gcc/9.2.0/.bin/../lib64/gcc/x86_64-suse-linux/9.2.0/specs
COLLECT_GCC=/xxx/gcc/9.2.0/.bin/g++
COLLECT_LTO_WRAPPER=/xxx/gcc/9.2.0/.bin/../libexec/gcc/x86_64-suse-linux/9.2.0/lto-wrapper
Target: x86_64-suse-linux
Configured with: ./configure --prefix=/xxx/gcc/9.2.0
--libdir=/xxx/gcc/9.2.0/lib64 --libexecdir=/xxx/gcc/9.2.0/libexec
--bindir=/xxx/gcc/9.2.0/bin --with-isl=/xxx/gcc/9.2.0
--with-libelf=/xxx/gcc/9.2.0 --with-mpfr=/xxx/gcc/9.2.0
--with-gmp=/xxx/gcc/9.2.0 --with-mpc=/xxx/gcc/9.2.0 --enable-gold=yes
--enable-lto --enable-languages=c,c++,objc,fortran --build=x86_64-suse-linux
--host=x86_64-suse-linux --target=x86_64-suse-linux --enable-libotm
--disable-libstdcxx-pch
Thread model: posix
gcc version 9.2.0 (GCC)

[Bug c++/90998] [9/10 Regression] ICE (segfalut) in gcc/cp/call.c compare_ics() with -std=c++17

2019-08-12 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90998

Jakub Jelinek  changed:

   What|Removed |Added

   Target Milestone|9.2 |9.3

--- Comment #2 from Jakub Jelinek  ---
GCC 9.2 has been released.

[Bug c++/90998] [9/10 Regression] ICE (segfalut) in gcc/cp/call.c compare_ics() with -std=c++17

2019-06-26 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90998

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2
Summary|[Regression] ICE (segfalut) |[9/10 Regression] ICE
   |in gcc/cp/call.c|(segfalut) in gcc/cp/call.c
   |compare_ics() with  |compare_ics() with
   |-std=c++17  |-std=c++17