Bug 93443 - gcc/cp/coroutines.cc:3555:23: runtime error: load of value 255, which is not a valid value for type 'bool'
Summary: gcc/cp/coroutines.cc:3555:23: runtime error: load of value 255, which is not ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 10.0
: P3 normal
Target Milestone: 10.0
Assignee: Iain Sandoe
URL:
Keywords:
Depends on:
Blocks: ubsan
  Show dependency treegraph
 
Reported: 2020-01-26 13:46 UTC by Martin Liška
Modified: 2020-02-20 08:57 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 10.0
Last reconfirmed: 2020-01-26 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2020-01-26 13:46:36 UTC
I see the following UBSAN which one can easily reproduce with:

diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 81fb8c924a7..0c4014c27da 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -3533,10 +3533,12 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer)
      logically doing things related to the end of the function.  */
   /* done, we just need the return value.  */
   bool no_warning;
+  bool no_warning_initialized = false;
   if (same_type_p (TREE_TYPE (gro), fn_return_type))
     {
       /* Already got the result.  */
       r = check_return_expr (DECL_RESULT (orig), &no_warning);
+      no_warning_initialized = true;
     }
   else
     {
@@ -3552,6 +3554,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer)
     }
 
   r = build_stmt (input_location, RETURN_EXPR, DECL_RESULT (orig));
+  gcc_assert (no_warning_initialized);
   TREE_NO_WARNING (r) |= no_warning;
   r = maybe_cleanup_point_expr_void (r);
   add_stmt (r);

$ g++ co-yield-03-tmpl.C -fcoroutines -c
co-yield-03-tmpl.C: In instantiation of ‘looper<T> f() [with T = int]’:
co-yield-03-tmpl.C:105:25:   required from here
co-yield-03-tmpl.C:99:1: internal compiler error: in morph_fn_to_coro, at cp/coroutines.cc:3557
   99 | }
      | ^
0xb1389f morph_fn_to_coro(tree_node*, tree_node**, tree_node**)
	../../gcc/cp/coroutines.cc:3557
0xc43e5e finish_function(bool)
	../../gcc/cp/decl.c:16853
0x103d3a1 instantiate_decl(tree_node*, bool, bool)
	../../gcc/cp/pt.c:25524
0x103e1e6 instantiate_pending_templates(int)
	../../gcc/cp/pt.c:25620
0xc90f2a c_parse_final_cleanups()
	../../gcc/cp/decl2.c:4871
0x13223d9 c_common_parse_file()
	../../gcc/c-family/c-opts.c:1208
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.
Comment 1 CVS Commits 2020-01-27 19:47:54 UTC
The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:

https://gcc.gnu.org/g:1f2e84238c9f079747804026b6225ec8c1d0e4b7

commit r10-6265-g1f2e84238c9f079747804026b6225ec8c1d0e4b7
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Mon Jan 27 10:13:09 2020 +0000

    coroutines: Ensure the ramp return object is checked (PR93443).
    
    As the PR shows, there is a pathway through the code where the
    no_warning value is not set, which corresponds to a missing check
    of the ramp return when it was constructed from the 'get return
    object'  Fixed by ensuring that the check of the return value is
    carried out for both return cases.
    
    gcc/cp/ChangeLog:
    
    2020-01-27  Iain Sandoe  <iain@sandoe.co.uk>
    
    	PR c++/93443
    	* coroutines.cc (morph_fn_to_coro): Check the ramp return
    	value when it is constructed from the 'get return object'.
Comment 2 Iain Sandoe 2020-02-20 08:56:31 UTC
AFAICS, this should be fixed now, yes?
Comment 3 Martin Liška 2020-02-20 08:57:12 UTC
Yes, it is.