[Bug c++/81167] [8 Regression] ICE on valid C++ code in deferred_printed_type, at cp/error.c:118

2018-01-19 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81167

Jakub Jelinek  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #11 from Jakub Jelinek  ---
Fixed.

[Bug c++/81167] [8 Regression] ICE on valid C++ code in deferred_printed_type, at cp/error.c:118

2018-01-19 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81167

--- Comment #10 from Jakub Jelinek  ---
Author: jakub
Date: Fri Jan 19 22:37:37 2018
New Revision: 256905

URL: https://gcc.gnu.org/viewcvs?rev=256905=gcc=rev
Log:
PR c++/81167
* call.c (joust): Use TREE_TYPE (source) if source is
a POINTER_TYPE_P rather than if ! DECL_CONSTRUCTOR_P (w->fn).

* g++.dg/cpp0x/pr81167.C: New test.

Added:
trunk/gcc/testsuite/g++.dg/cpp0x/pr81167.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/call.c
trunk/gcc/testsuite/ChangeLog

[Bug c++/81167] [8 Regression] ICE on valid C++ code in deferred_printed_type, at cp/error.c:118

2018-01-18 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81167

--- Comment #9 from Jakub Jelinek  ---
Created attachment 43180
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43180=edit
gcc8-pr81167.patch

Untested fix.  This assumes that the type we want as source is always some
class type, which seems to be the case at least in all the testsuite coverage
we have for this.

[Bug c++/81167] [8 Regression] ICE on valid C++ code in deferred_printed_type, at cp/error.c:118

2018-01-18 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81167

--- Comment #8 from Jakub Jelinek  ---
In gcc/testsuite/ we apparently have just g++.old-deja/g++.benjamin/16077.C
and g++.old-deja/g++.other/overcnv2.C testcases covering those and in both
cases
source is a POINTER_TYPE.
With check-c++-all RUNTESTFLAGS='--target_board=unix/-Wconversion' I managed to
get a few extras:
gcc/testsuite/g++.dg/cpp0x/initlist64.C (nofn) struct Y * vs. struct X
gcc/testsuite/g++.dg/cpp0x/initlist64.C (nofn) struct Z * vs. struct X
gcc/testsuite/g++.dg/cpp1y/context-conv1.C f struct zero_init * vs. int *
gcc/gcc/testsuite/g++.old-deja/g++.benjamin/16077.C foo struct nicaragua * vs.
struct colombia
gcc/testsuite/g++.old-deja/g++.mike/p807.C main struct AX * vs. struct B
gcc/testsuite/g++.old-deja/g++.other/overcnv2.C main struct B * vs. const char
*

[Bug c++/81167] [8 Regression] ICE on valid C++ code in deferred_printed_type, at cp/error.c:118

2018-01-18 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81167

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org,
   ||jason at gcc dot gnu.org,
   ||nathan at gcc dot gnu.org

--- Comment #7 from Jakub Jelinek  ---
I think it is fine that %H/%I crash on bogus arguments, but we should fix here
the real bug.
+ if (! DECL_CONSTRUCTOR_P (w->fn)
+  && TREE_TYPE (source))
looks just like a workaround.  The main question is what is:
  tree source = source_type (w->convs[0]);
  if (! DECL_CONSTRUCTOR_P (w->fn))
source = TREE_TYPE (source);
code meant to do exactly, I bet it relies on the assumption that this argument
to w->fn must be a POINTER_TYPE_P, but in this case source is neither pointer
nor reference type, because source_type looked through the ck_ref_bind
conversion which had reference to bar type to the next conversion which is
ck_identity with bar type.  So, source already is a RECORD_TYPE rather than a
pointer/reference.

[Bug c++/81167] [8 Regression] ICE on valid C++ code in deferred_printed_type, at cp/error.c:118

2018-01-10 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81167

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P1

[Bug c++/81167] [8 Regression] ICE on valid C++ code in deferred_printed_type, at cp/error.c:118

2017-06-22 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81167

--- Comment #6 from David Malcolm  ---
Candidate patch for the ICE posted here:
  https://gcc.gnu.org/ml/gcc-patches/2017-06/msg01725.html

Actually fixing the diagnostic as per comment #5 would be a separate patch.

[Bug c++/81167] [8 Regression] ICE on valid C++ code in deferred_printed_type, at cp/error.c:118

2017-06-22 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81167

--- Comment #5 from David Malcolm  ---
Note to self: I believe the "operator T() &&" here is a user-defined conversion
from an rvalue reference to T.

We have in joust at ../../src/gcc/cp/call.c:10071

10071 tree source = source_type (w->convs[0]);

(gdb) p source
$2 = 

10072 if (! DECL_CONSTRUCTOR_P (w->fn))
10073   source = TREE_TYPE (source);

(gdb) p source
$4 = 

Guarding that as follows:

--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -10069,7 +10069,8 @@ joust (struct z_candidate *cand1, struct z_candidate
*cand2, bool warn,
   else if (warn)
{
  tree source = source_type (w->convs[0]);
- if (! DECL_CONSTRUCTOR_P (w->fn))
+ if (! DECL_CONSTRUCTOR_P (w->fn)
+  && TREE_TYPE (source))
source = TREE_TYPE (source);
  if (warning (OPT_Wconversion, "choosing %qD over %qD", w->fn, l->fn)
  && warning (OPT_Wconversion, "  for conversion from %qH to %qI",

fixes the problem (or papers over it?), giving:

../../src/pr81167.C: In function ‘void test()’:
../../src/pr81167.C:16:16: warning: choosing ‘bar::operator foo() &&’ over
‘foo::foo(const bar&)’ [-Wconversion]
   foo f = bar ();
^
../../src/pr81167.C:16:16: warning:   for conversion from ‘bar’ to ‘foo’
[-Wconversion]
../../src/pr81167.C:16:16: note:   because conversion sequence for the argument
is better

[Bug c++/81167] [8 Regression] ICE on valid C++ code in deferred_printed_type, at cp/error.c:118

2017-06-22 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81167

--- Comment #4 from David Malcolm  ---
Minimal reproducer:

$ cat ../../src/pr81167.C
struct bar;

struct foo
{
  foo () {}
  foo (const bar &) {}
};

struct bar
{
  operator foo() && { return foo (); }
};

void test ()
{
  foo f = bar ();
}

$ ./xg++ -B. ../../src/pr81167.C  -Wconversion
../../src/pr81167.C: In function ‘void test()’:
../../src/pr81167.C:16:16: warning: choosing ‘bar::operator foo() &&’ over
‘foo::foo(const bar&)’ [-Wconversion]
   foo f = bar ();
^
‘
in deferred_printed_type, at cp/error.c:118
0x908c9e deferred_printed_type::deferred_printed_type(tree_node*, char const**,
bool, bool)
../../src/gcc/cp/error.c:118
0x907de4 defer_phase_2_of_type_diff
../../src/gcc/cp/error.c:3985
0x9083a1 cp_printer
../../src/gcc/cp/error.c:4062
0x1acf511 pp_format(pretty_printer*, text_info*)
../../src/gcc/pretty-print.c:679
0x1ab722a diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
../../src/gcc/diagnostic.c:974
0x1ab77a0 diagnostic_impl
../../src/gcc/diagnostic.c:1099
0x1ab7cef warning(int, char const*, ...)
../../src/gcc/diagnostic.c:1187
0x7edc64 joust
../../src/gcc/cp/call.c:10076
0x7e267a build_over_call
../../src/gcc/cp/call.c:7623
0x7dee82 convert_like_real
../../src/gcc/cp/call.c:6757
0x7dfa4a convert_like_real
../../src/gcc/cp/call.c:6873
0x7d4010 build_user_type_conversion(tree_node*, tree_node*, int, int)
../../src/gcc/cp/call.c:3995
0x870c39 ocp_convert(tree_node*, tree_node*, int, int, int)
../../src/gcc/cp/cvt.c:889
0x918775 expand_default_init
../../src/gcc/cp/init.c:1789
0x9193f5 expand_aggr_init_1
../../src/gcc/cp/init.c:1968
0x917fa1 build_aggr_init(tree_node*, tree_node*, int, int)
../../src/gcc/cp/init.c:1706
0x8a12df build_aggr_init_full_exprs
../../src/gcc/cp/decl.c:6128
0x8a21ff check_initializer
../../src/gcc/cp/decl.c:6276
0x8a5df7 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
../../src/gcc/cp/decl.c:6995
0x9a9b16 cp_parser_init_declarator
../../src/gcc/cp/parser.c:19393
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

[Bug c++/81167] [8 Regression] ICE on valid C++ code in deferred_printed_type, at cp/error.c:118

2017-06-22 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81167

--- Comment #3 from David Malcolm  ---
The issue is that a diagnostic is passing NULL to a %qH (which was a %qT).

%T handles NULL gracefully by printing the empty string,
whereas %H/%I fail with an assertion failure.

Happens here:
#8  0x0081469e in joust(z_candidate*, z_candidate*, bool, int) [clone
.part.38] ()
at ../../src/gcc/cp/call.c:10075

10075 && warning (OPT_Wconversion, "  for conversion from %qH
to %qI",
10076 source, w->second_conv->type)) 

(gdb) p source
$2 = (tree_node *) 0x0
(gdb) p w->second_conv->type
$3 = 

[Bug c++/81167] [8 Regression] ICE on valid C++ code in deferred_printed_type, at cp/error.c:118

2017-06-22 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81167

David Malcolm  changed:

   What|Removed |Added

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

--- Comment #2 from David Malcolm  ---
Thanks; am investigating...

[Bug c++/81167] [8 Regression] ICE on valid C++ code in deferred_printed_type, at cp/error.c:118

2017-06-22 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81167

Richard Biener  changed:

   What|Removed |Added

Version|7.0 |8.0
   Target Milestone|--- |8.0

[Bug c++/81167] [8 Regression] ICE on valid C++ code in deferred_printed_type, at cp/error.c:118

2017-06-22 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81167

Martin Liška  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-06-22
 Ever confirmed|0   |1

[Bug c++/81167] [8 Regression] ICE on valid C++ code in deferred_printed_type, at cp/error.c:118

2017-06-22 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81167

--- Comment #1 from Martin Liška  ---
Created attachment 41606
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41606=edit
test-case