c++: Fix ICE with static_cast when converting from int[] [PR93862]
authorMarek Polacek <polacek@redhat.com>
Mon, 24 Feb 2020 19:43:48 +0000 (14:43 -0500)
committerMarek Polacek <polacek@redhat.com>
Wed, 26 Feb 2020 15:18:30 +0000 (10:18 -0500)
commit4a305fa2fd4c9d553b26efa00f868aa1e4416a9f
treebeda3667124a850b4d69abfe295d39726c9d5905
parentb9934ad88d6b27e5cf1a34d88dbefb2bbe928753
c++: Fix ICE with static_cast when converting from int[] [PR93862]

This ICEs since my patch for P0388, which allowed conversions to arrays
of unknown bound, but not the reverse, so these two static_casts are
ill-formed.

[expr.static.cast]/3 says that "cv1 T1" and "cv2 T2" have to be
reference-compatible and the comment in build_static_cast_1 says it too
but then we actually use reference_related_p...  Fixed thus.

2020-02-26  Marek Polacek  <polacek@redhat.com>

PR c++/93862 - ICE with static_cast when converting from int[].
* call.c (reference_compatible_p): No longer static.
* cp-tree.h (reference_compatible_p): Declare.
* typeck.c (build_static_cast_1): Use reference_compatible_p instead
of reference_related_p.

* g++.dg/cpp0x/rv-cast7.C: New test.
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/cp-tree.h
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/rv-cast7.C [new file with mode: 0644]