* C++ PATCH for c++/86201, diagnostic routines re-entered crash
@ 2018-07-03 16:08 Marek Polacek
2018-07-03 16:33 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2018-07-03 16:08 UTC (permalink / raw)
To: GCC Patches, Jason Merrill
This is an ICE of kind "Error reporting routines re-entered". From the PR:
The problem here is that we report the missing return value:
9224 permerror (input_location, "return-statement with no value, in "
9225 "function returning %qT", valtype);
but permerror will end up calling print_instantiation_full_context, which ends
up calling dump_template_bindings and then tsubst -> tsubst_copy_and_build ->
build_functional_cast -> ... -> ocp_convert which has (complain is tf_none)
829 if (complain & tf_warning)
830 return cp_truthvalue_conversion (e);
831 else
832 {
833 /* Prevent bogus -Wint-in-bool-context warnings coming
834 from c_common_truthvalue_conversion down the line. */
835 warning_sentinel w (warn_int_in_bool_context);
836 return cp_truthvalue_conversion (e);
837 }
So we call cp_truthvalue_conversion -> c_common_truthvalue_conversion ->
build_binary_op which only calls cp_build_binary_op but with
tf_warning_or_error. So even though the warning
4736 if ((complain & tf_warning)
4737 && (FLOAT_TYPE_P (type0) || FLOAT_TYPE_P (type1)))
4738 warning (OPT_Wfloat_equal,
4739 "comparing floating point with == or != is unsafe");
is properly guarded, we still re-enter the diagnostic routines.
But since we're parsing decltype we can check c_inhibit_evaluation_warnings
which means we won't call warning().
Bootstrapped/regtested on x86_64-linux, ok for trunk?
2018-07-03 Marek Polacek <polacek@redhat.com>
PR c++/86201
* typeck.c (cp_build_binary_op): Check c_inhibit_evaluation_warnings.
* g++.dg/diagnostic/pr86201.C: New test.
diff --git gcc/cp/typeck.c gcc/cp/typeck.c
index 3a4f1cdf479..ea4ce9649cd 100644
--- gcc/cp/typeck.c
+++ gcc/cp/typeck.c
@@ -4734,6 +4734,7 @@ cp_build_binary_op (location_t location,
if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE)
goto vector_compare;
if ((complain & tf_warning)
+ && c_inhibit_evaluation_warnings == 0
&& (FLOAT_TYPE_P (type0) || FLOAT_TYPE_P (type1)))
warning (OPT_Wfloat_equal,
"comparing floating point with == or != is unsafe");
diff --git gcc/testsuite/g++.dg/diagnostic/pr86201.C gcc/testsuite/g++.dg/diagnostic/pr86201.C
index e69de29bb2d..e7019c22d95 100644
--- gcc/testsuite/g++.dg/diagnostic/pr86201.C
+++ gcc/testsuite/g++.dg/diagnostic/pr86201.C
@@ -0,0 +1,12 @@
+// PR c++/86201
+// { dg-do compile { target c++11 } }
+
+template <class U, class V>
+auto fn1 (V&& v) -> decltype(U(v))
+{
+ return; // { dg-error "return-statement with no value" }
+}
+void fn2 ()
+{
+ fn1<bool>(1.0);
+}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: C++ PATCH for c++/86201, diagnostic routines re-entered crash
2018-07-03 16:08 C++ PATCH for c++/86201, diagnostic routines re-entered crash Marek Polacek
@ 2018-07-03 16:33 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2018-07-03 16:33 UTC (permalink / raw)
To: Marek Polacek; +Cc: GCC Patches
OK.
On Tue, Jul 3, 2018 at 12:08 PM, Marek Polacek <polacek@redhat.com> wrote:
> This is an ICE of kind "Error reporting routines re-entered". From the PR:
>
> The problem here is that we report the missing return value:
> 9224 permerror (input_location, "return-statement with no value, in "
> 9225 "function returning %qT", valtype);
> but permerror will end up calling print_instantiation_full_context, which ends
> up calling dump_template_bindings and then tsubst -> tsubst_copy_and_build ->
> build_functional_cast -> ... -> ocp_convert which has (complain is tf_none)
> 829 if (complain & tf_warning)
> 830 return cp_truthvalue_conversion (e);
> 831 else
> 832 {
> 833 /* Prevent bogus -Wint-in-bool-context warnings coming
> 834 from c_common_truthvalue_conversion down the line. */
> 835 warning_sentinel w (warn_int_in_bool_context);
> 836 return cp_truthvalue_conversion (e);
> 837 }
> So we call cp_truthvalue_conversion -> c_common_truthvalue_conversion ->
> build_binary_op which only calls cp_build_binary_op but with
> tf_warning_or_error. So even though the warning
> 4736 if ((complain & tf_warning)
> 4737 && (FLOAT_TYPE_P (type0) || FLOAT_TYPE_P (type1)))
> 4738 warning (OPT_Wfloat_equal,
> 4739 "comparing floating point with == or != is unsafe");
> is properly guarded, we still re-enter the diagnostic routines.
>
> But since we're parsing decltype we can check c_inhibit_evaluation_warnings
> which means we won't call warning().
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>
> 2018-07-03 Marek Polacek <polacek@redhat.com>
>
> PR c++/86201
> * typeck.c (cp_build_binary_op): Check c_inhibit_evaluation_warnings.
>
> * g++.dg/diagnostic/pr86201.C: New test.
>
> diff --git gcc/cp/typeck.c gcc/cp/typeck.c
> index 3a4f1cdf479..ea4ce9649cd 100644
> --- gcc/cp/typeck.c
> +++ gcc/cp/typeck.c
> @@ -4734,6 +4734,7 @@ cp_build_binary_op (location_t location,
> if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE)
> goto vector_compare;
> if ((complain & tf_warning)
> + && c_inhibit_evaluation_warnings == 0
> && (FLOAT_TYPE_P (type0) || FLOAT_TYPE_P (type1)))
> warning (OPT_Wfloat_equal,
> "comparing floating point with == or != is unsafe");
> diff --git gcc/testsuite/g++.dg/diagnostic/pr86201.C gcc/testsuite/g++.dg/diagnostic/pr86201.C
> index e69de29bb2d..e7019c22d95 100644
> --- gcc/testsuite/g++.dg/diagnostic/pr86201.C
> +++ gcc/testsuite/g++.dg/diagnostic/pr86201.C
> @@ -0,0 +1,12 @@
> +// PR c++/86201
> +// { dg-do compile { target c++11 } }
> +
> +template <class U, class V>
> +auto fn1 (V&& v) -> decltype(U(v))
> +{
> + return; // { dg-error "return-statement with no value" }
> +}
> +void fn2 ()
> +{
> + fn1<bool>(1.0);
> +}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-03 16:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-03 16:08 C++ PATCH for c++/86201, diagnostic routines re-entered crash Marek Polacek
2018-07-03 16:33 ` Jason Merrill
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).